Skip to content

Commit

Permalink
net: Make qdisc_skb_cb upper size bound explicit.
Browse files Browse the repository at this point in the history
Just like skb->cb[], so that qdisc_skb_cb can be encapsulated inside
of other data structures.

This is intended to be used by IPoIB so that it can remember
addressing information stored at hard_header_ops->create() time that
it can fetch when the packet gets to the transmit routine.

Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
David S. Miller committed Feb 6, 2012
1 parent c056b73 commit a0417fa
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 10 deletions.
9 changes: 8 additions & 1 deletion include/net/sch_generic.h
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,16 @@ struct tcf_proto {

struct qdisc_skb_cb {
unsigned int pkt_len;
long data[];
unsigned char data[24];
};

static inline void qdisc_cb_private_validate(const struct sk_buff *skb, int sz)
{
struct qdisc_skb_cb *qcb;
BUILD_BUG_ON(sizeof(skb->cb) < sizeof(unsigned int) + sz);
BUILD_BUG_ON(sizeof(qcb->data) < sz);
}

static inline int qdisc_qlen(const struct Qdisc *q)
{
return q->q.qlen;
Expand Down
3 changes: 1 addition & 2 deletions net/sched/sch_choke.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,7 @@ struct choke_skb_cb {

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));
qdisc_cb_private_validate(skb, sizeof(struct choke_skb_cb));
return (struct choke_skb_cb *)qdisc_skb_cb(skb)->data;
}

Expand Down
3 changes: 1 addition & 2 deletions net/sched/sch_netem.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,7 @@ struct netem_skb_cb {

static inline struct netem_skb_cb *netem_skb_cb(struct sk_buff *skb)
{
BUILD_BUG_ON(sizeof(skb->cb) <
sizeof(struct qdisc_skb_cb) + sizeof(struct netem_skb_cb));
qdisc_cb_private_validate(skb, sizeof(struct netem_skb_cb));
return (struct netem_skb_cb *)qdisc_skb_cb(skb)->data;
}

Expand Down
3 changes: 1 addition & 2 deletions net/sched/sch_sfb.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,7 @@ struct sfb_skb_cb {

static inline struct sfb_skb_cb *sfb_skb_cb(const struct sk_buff *skb)
{
BUILD_BUG_ON(sizeof(skb->cb) <
sizeof(struct qdisc_skb_cb) + sizeof(struct sfb_skb_cb));
qdisc_cb_private_validate(skb, sizeof(struct sfb_skb_cb));
return (struct sfb_skb_cb *)qdisc_skb_cb(skb)->data;
}

Expand Down
5 changes: 2 additions & 3 deletions net/sched/sch_sfq.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,8 @@ struct sfq_skb_cb {

static inline struct sfq_skb_cb *sfq_skb_cb(const struct sk_buff *skb)
{
BUILD_BUG_ON(sizeof(skb->cb) <
sizeof(struct qdisc_skb_cb) + sizeof(struct sfq_skb_cb));
return (struct sfq_skb_cb *)qdisc_skb_cb(skb)->data;
qdisc_cb_private_validate(skb, sizeof(struct sfq_skb_cb));
return (struct sfq_skb_cb *)qdisc_skb_cb(skb)->data;
}

static unsigned int sfq_hash(const struct sfq_sched_data *q,
Expand Down

0 comments on commit a0417fa

Please sign in to comment.