Commit 9c4d8938 authored by Stephen Hemminger's avatar Stephen Hemminger

[NET]: Use unlikely and BUG_ON in SKB assertions.

parent 542b8ab9
......@@ -803,12 +803,9 @@ static inline void skb_fill_page_desc(struct sk_buff *skb, int i, struct page *p
skb_shinfo(skb)->nr_frags = i+1;
}
#define SKB_PAGE_ASSERT(skb) do { if (skb_shinfo(skb)->nr_frags) \
BUG(); } while (0)
#define SKB_FRAG_ASSERT(skb) do { if (skb_shinfo(skb)->frag_list) \
BUG(); } while (0)
#define SKB_LINEAR_ASSERT(skb) do { if (skb_is_nonlinear(skb)) \
BUG(); } while (0)
#define SKB_PAGE_ASSERT(skb) BUG_ON(skb_shinfo(skb)->nr_frags)
#define SKB_FRAG_ASSERT(skb) BUG_ON(skb_shinfo(skb)->frag_list)
#define SKB_LINEAR_ASSERT(skb) BUG_ON(skb_is_nonlinear(skb))
/*
* Add data to an sk_buff
......@@ -837,7 +834,7 @@ static inline unsigned char *skb_put(struct sk_buff *skb, unsigned int len)
SKB_LINEAR_ASSERT(skb);
skb->tail += len;
skb->len += len;
if (skb->tail>skb->end)
if (unlikely(skb->tail>skb->end))
skb_over_panic(skb, len, current_text_addr());
return tmp;
}
......@@ -862,7 +859,7 @@ static inline unsigned char *skb_push(struct sk_buff *skb, unsigned int len)
{
skb->data -= len;
skb->len += len;
if (skb->data<skb->head)
if (unlikely(skb->data<skb->head))
skb_under_panic(skb, len, current_text_addr());
return skb->data;
}
......@@ -870,8 +867,7 @@ static inline unsigned char *skb_push(struct sk_buff *skb, unsigned int len)
static inline char *__skb_pull(struct sk_buff *skb, unsigned int len)
{
skb->len -= len;
if (skb->len < skb->data_len)
BUG();
BUG_ON(skb->len < skb->data_len);
return skb->data += len;
}
......@@ -1137,8 +1133,7 @@ static inline int __deprecated skb_linearize(struct sk_buff *skb, int gfp)
static inline void *kmap_skb_frag(const skb_frag_t *frag)
{
#ifdef CONFIG_HIGHMEM
if (in_irq())
BUG();
BUG_ON(in_irq());
local_bh_disable();
#endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment