* [PATCH net-next-2.6] sch_choke: add choke_skb_cb
@ 2011-02-25 3:45 Eric Dumazet
2011-02-25 3:48 ` Stephen Hemminger
2011-02-25 6:14 ` David Miller
0 siblings, 2 replies; 4+ messages in thread
From: Eric Dumazet @ 2011-02-25 3:45 UTC (permalink / raw)
To: David Miller; +Cc: netdev, Stephen Hemminger, Patrick McHardy
Better document choke skb->cb[] use, like we did in netem and sfb
This adds a compile time check to make sure we dont exhaust skb->cb[]
space.
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
CC: Stephen Hemminger <shemminger@vyatta.com>
CC: Patrick McHardy <kaber@trash.net>
---
net/sched/sch_choke.c | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/net/sched/sch_choke.c b/net/sched/sch_choke.c
index ee1e209..06afbae 100644
--- a/net/sched/sch_choke.c
+++ b/net/sched/sch_choke.c
@@ -219,14 +219,25 @@ static bool choke_match_flow(struct sk_buff *skb1,
return *ports1 == *ports2;
}
+struct choke_skb_cb {
+ u16 classid;
+};
+
+static inline struct choke_skb_cb *choke_skb_cb(const struct sk_buff *skb)
+{
+ BUILD_BUG_ON(sizeof(skb->cb) <
+ sizeof(struct qdisc_skb_cb) + sizeof(struct choke_skb_cb));
+ return (struct choke_skb_cb *)qdisc_skb_cb(skb)->data;
+}
+
static inline void choke_set_classid(struct sk_buff *skb, u16 classid)
{
- *(unsigned int *)(qdisc_skb_cb(skb)->data) = classid;
+ choke_skb_cb(skb)->classid = classid;
}
static u16 choke_get_classid(const struct sk_buff *skb)
{
- return *(unsigned int *)(qdisc_skb_cb(skb)->data);
+ return choke_skb_cb(skb)->classid;
}
/*
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH net-next-2.6] sch_choke: add choke_skb_cb
2011-02-25 3:45 [PATCH net-next-2.6] sch_choke: add choke_skb_cb Eric Dumazet
@ 2011-02-25 3:48 ` Stephen Hemminger
2011-02-25 3:54 ` Eric Dumazet
2011-02-25 6:14 ` David Miller
1 sibling, 1 reply; 4+ messages in thread
From: Stephen Hemminger @ 2011-02-25 3:48 UTC (permalink / raw)
To: Eric Dumazet; +Cc: David Miller, netdev, Patrick McHardy
On Fri, 25 Feb 2011 04:45:41 +0100
Eric Dumazet <eric.dumazet@gmail.com> wrote:
> Better document choke skb->cb[] use, like we did in netem and sfb
>
> This adds a compile time check to make sure we dont exhaust skb->cb[]
> space.
>
> Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
> CC: Stephen Hemminger <shemminger@vyatta.com>
> CC: Patrick McHardy <kaber@trash.net>
> ---
> net/sched/sch_choke.c | 15 +++++++++++++--
> 1 file changed, 13 insertions(+), 2 deletions(-)
>
> diff --git a/net/sched/sch_choke.c b/net/sched/sch_choke.c
> index ee1e209..06afbae 100644
> --- a/net/sched/sch_choke.c
> +++ b/net/sched/sch_choke.c
> @@ -219,14 +219,25 @@ static bool choke_match_flow(struct sk_buff *skb1,
> return *ports1 == *ports2;
> }
>
> +struct choke_skb_cb {
> + u16 classid;
> +};
> +
> +static inline struct choke_skb_cb *choke_skb_cb(const struct sk_buff *skb)
> +{
> + BUILD_BUG_ON(sizeof(skb->cb) <
> + sizeof(struct qdisc_skb_cb) + sizeof(struct choke_skb_cb));
> + return (struct choke_skb_cb *)qdisc_skb_cb(skb)->data;
> +}
> +
> static inline void choke_set_classid(struct sk_buff *skb, u16 classid)
> {
> - *(unsigned int *)(qdisc_skb_cb(skb)->data) = classid;
> + choke_skb_cb(skb)->classid = classid;
> }
>
> static u16 choke_get_classid(const struct sk_buff *skb)
> {
> - return *(unsigned int *)(qdisc_skb_cb(skb)->data);
> + return choke_skb_cb(skb)->classid;
> }
>
Ideally class id should be u32, but then that would mean changing TC
classifier id and that is hardwired into the API.
--
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net-next-2.6] sch_choke: add choke_skb_cb
2011-02-25 3:48 ` Stephen Hemminger
@ 2011-02-25 3:54 ` Eric Dumazet
0 siblings, 0 replies; 4+ messages in thread
From: Eric Dumazet @ 2011-02-25 3:54 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: David Miller, netdev, Patrick McHardy
Le jeudi 24 février 2011 à 19:48 -0800, Stephen Hemminger a écrit :
> Ideally class id should be u32, but then that would mean changing TC
> classifier id and that is hardwired into the API.
>
>
Yes, this is a bit disappointing, especially if we want to use rxhash
from external classifier (same problem for SFQ)
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net-next-2.6] sch_choke: add choke_skb_cb
2011-02-25 3:45 [PATCH net-next-2.6] sch_choke: add choke_skb_cb Eric Dumazet
2011-02-25 3:48 ` Stephen Hemminger
@ 2011-02-25 6:14 ` David Miller
1 sibling, 0 replies; 4+ messages in thread
From: David Miller @ 2011-02-25 6:14 UTC (permalink / raw)
To: eric.dumazet; +Cc: netdev, shemminger, kaber
From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Fri, 25 Feb 2011 04:45:41 +0100
> Better document choke skb->cb[] use, like we did in netem and sfb
>
> This adds a compile time check to make sure we dont exhaust skb->cb[]
> space.
>
> Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
> CC: Stephen Hemminger <shemminger@vyatta.com>
> CC: Patrick McHardy <kaber@trash.net>
Applied.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-02-25 6:14 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-02-25 3:45 [PATCH net-next-2.6] sch_choke: add choke_skb_cb Eric Dumazet
2011-02-25 3:48 ` Stephen Hemminger
2011-02-25 3:54 ` Eric Dumazet
2011-02-25 6:14 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).