Skip to content

Commit

Permalink
sch_choke: add choke_skb_cb
Browse files Browse the repository at this point in the history
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>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Eric Dumazet authored and David S. Miller committed Feb 25, 2011
1 parent 250a65f commit 26f70e1
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions net/sched/sch_choke.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/*
Expand Down

0 comments on commit 26f70e1

Please sign in to comment.