aboutsummaryrefslogtreecommitdiffstats
path: root/net/core/skbuff.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/core/skbuff.c')
-rw-r--r--net/core/skbuff.c80
1 files changed, 21 insertions, 59 deletions
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 88c613eab142..d1967dab9cc6 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -2865,7 +2865,6 @@ static void skb_ts_finish(struct ts_config *conf, struct ts_state *state)
2865 * @from: search offset 2865 * @from: search offset
2866 * @to: search limit 2866 * @to: search limit
2867 * @config: textsearch configuration 2867 * @config: textsearch configuration
2868 * @state: uninitialized textsearch state variable
2869 * 2868 *
2870 * Finds a pattern in the skb data according to the specified 2869 * Finds a pattern in the skb data according to the specified
2871 * textsearch configuration. Use textsearch_next() to retrieve 2870 * textsearch configuration. Use textsearch_next() to retrieve
@@ -2873,17 +2872,17 @@ static void skb_ts_finish(struct ts_config *conf, struct ts_state *state)
2873 * to the first occurrence or UINT_MAX if no match was found. 2872 * to the first occurrence or UINT_MAX if no match was found.
2874 */ 2873 */
2875unsigned int skb_find_text(struct sk_buff *skb, unsigned int from, 2874unsigned int skb_find_text(struct sk_buff *skb, unsigned int from,
2876 unsigned int to, struct ts_config *config, 2875 unsigned int to, struct ts_config *config)
2877 struct ts_state *state)
2878{ 2876{
2877 struct ts_state state;
2879 unsigned int ret; 2878 unsigned int ret;
2880 2879
2881 config->get_next_block = skb_ts_get_next_block; 2880 config->get_next_block = skb_ts_get_next_block;
2882 config->finish = skb_ts_finish; 2881 config->finish = skb_ts_finish;
2883 2882
2884 skb_prepare_seq_read(skb, from, to, TS_SKB_CB(state)); 2883 skb_prepare_seq_read(skb, from, to, TS_SKB_CB(&state));
2885 2884
2886 ret = textsearch_find(config, state); 2885 ret = textsearch_find(config, &state);
2887 return (ret <= to - from ? ret : UINT_MAX); 2886 return (ret <= to - from ? ret : UINT_MAX);
2888} 2887}
2889EXPORT_SYMBOL(skb_find_text); 2888EXPORT_SYMBOL(skb_find_text);
@@ -3207,10 +3206,9 @@ int skb_gro_receive(struct sk_buff **head, struct sk_buff *skb)
3207 struct skb_shared_info *pinfo, *skbinfo = skb_shinfo(skb); 3206 struct skb_shared_info *pinfo, *skbinfo = skb_shinfo(skb);
3208 unsigned int offset = skb_gro_offset(skb); 3207 unsigned int offset = skb_gro_offset(skb);
3209 unsigned int headlen = skb_headlen(skb); 3208 unsigned int headlen = skb_headlen(skb);
3210 struct sk_buff *nskb, *lp, *p = *head;
3211 unsigned int len = skb_gro_len(skb); 3209 unsigned int len = skb_gro_len(skb);
3210 struct sk_buff *lp, *p = *head;
3212 unsigned int delta_truesize; 3211 unsigned int delta_truesize;
3213 unsigned int headroom;
3214 3212
3215 if (unlikely(p->len + len >= 65536)) 3213 if (unlikely(p->len + len >= 65536))
3216 return -E2BIG; 3214 return -E2BIG;
@@ -3277,48 +3275,6 @@ int skb_gro_receive(struct sk_buff **head, struct sk_buff *skb)
3277 NAPI_GRO_CB(skb)->free = NAPI_GRO_FREE_STOLEN_HEAD; 3275 NAPI_GRO_CB(skb)->free = NAPI_GRO_FREE_STOLEN_HEAD;
3278 goto done; 3276 goto done;
3279 } 3277 }
3280 /* switch back to head shinfo */
3281 pinfo = skb_shinfo(p);
3282
3283 if (pinfo->frag_list)
3284 goto merge;
3285 if (skb_gro_len(p) != pinfo->gso_size)
3286 return -E2BIG;
3287
3288 headroom = skb_headroom(p);
3289 nskb = alloc_skb(headroom + skb_gro_offset(p), GFP_ATOMIC);
3290 if (unlikely(!nskb))
3291 return -ENOMEM;
3292
3293 __copy_skb_header(nskb, p);
3294 nskb->mac_len = p->mac_len;
3295
3296 skb_reserve(nskb, headroom);
3297 __skb_put(nskb, skb_gro_offset(p));
3298
3299 skb_set_mac_header(nskb, skb_mac_header(p) - p->data);
3300 skb_set_network_header(nskb, skb_network_offset(p));
3301 skb_set_transport_header(nskb, skb_transport_offset(p));
3302
3303 __skb_pull(p, skb_gro_offset(p));
3304 memcpy(skb_mac_header(nskb), skb_mac_header(p),
3305 p->data - skb_mac_header(p));
3306
3307 skb_shinfo(nskb)->frag_list = p;
3308 skb_shinfo(nskb)->gso_size = pinfo->gso_size;
3309 pinfo->gso_size = 0;
3310 __skb_header_release(p);
3311 NAPI_GRO_CB(nskb)->last = p;
3312
3313 nskb->data_len += p->len;
3314 nskb->truesize += p->truesize;
3315 nskb->len += p->len;
3316
3317 *head = nskb;
3318 nskb->next = p->next;
3319 p->next = NULL;
3320
3321 p = nskb;
3322 3278
3323merge: 3279merge:
3324 delta_truesize = skb->truesize; 3280 delta_truesize = skb->truesize;
@@ -3621,13 +3577,14 @@ struct sk_buff *sock_dequeue_err_skb(struct sock *sk)
3621{ 3577{
3622 struct sk_buff_head *q = &sk->sk_error_queue; 3578 struct sk_buff_head *q = &sk->sk_error_queue;
3623 struct sk_buff *skb, *skb_next; 3579 struct sk_buff *skb, *skb_next;
3580 unsigned long flags;
3624 int err = 0; 3581 int err = 0;
3625 3582
3626 spin_lock_bh(&q->lock); 3583 spin_lock_irqsave(&q->lock, flags);
3627 skb = __skb_dequeue(q); 3584 skb = __skb_dequeue(q);
3628 if (skb && (skb_next = skb_peek(q))) 3585 if (skb && (skb_next = skb_peek(q)))
3629 err = SKB_EXT_ERR(skb_next)->ee.ee_errno; 3586 err = SKB_EXT_ERR(skb_next)->ee.ee_errno;
3630 spin_unlock_bh(&q->lock); 3587 spin_unlock_irqrestore(&q->lock, flags);
3631 3588
3632 sk->sk_err = err; 3589 sk->sk_err = err;
3633 if (err) 3590 if (err)
@@ -3732,9 +3689,13 @@ void __skb_tstamp_tx(struct sk_buff *orig_skb,
3732 struct sock *sk, int tstype) 3689 struct sock *sk, int tstype)
3733{ 3690{
3734 struct sk_buff *skb; 3691 struct sk_buff *skb;
3735 bool tsonly = sk->sk_tsflags & SOF_TIMESTAMPING_OPT_TSONLY; 3692 bool tsonly;
3693
3694 if (!sk)
3695 return;
3736 3696
3737 if (!sk || !skb_may_tx_timestamp(sk, tsonly)) 3697 tsonly = sk->sk_tsflags & SOF_TIMESTAMPING_OPT_TSONLY;
3698 if (!skb_may_tx_timestamp(sk, tsonly))
3738 return; 3699 return;
3739 3700
3740 if (tsonly) 3701 if (tsonly)
@@ -3791,7 +3752,6 @@ void skb_complete_wifi_ack(struct sk_buff *skb, bool acked)
3791} 3752}
3792EXPORT_SYMBOL_GPL(skb_complete_wifi_ack); 3753EXPORT_SYMBOL_GPL(skb_complete_wifi_ack);
3793 3754
3794
3795/** 3755/**
3796 * skb_partial_csum_set - set up and verify partial csum values for packet 3756 * skb_partial_csum_set - set up and verify partial csum values for packet
3797 * @skb: the skb to set 3757 * @skb: the skb to set
@@ -4164,19 +4124,21 @@ EXPORT_SYMBOL(skb_try_coalesce);
4164 */ 4124 */
4165void skb_scrub_packet(struct sk_buff *skb, bool xnet) 4125void skb_scrub_packet(struct sk_buff *skb, bool xnet)
4166{ 4126{
4167 if (xnet)
4168 skb_orphan(skb);
4169 skb->tstamp.tv64 = 0; 4127 skb->tstamp.tv64 = 0;
4170 skb->pkt_type = PACKET_HOST; 4128 skb->pkt_type = PACKET_HOST;
4171 skb->skb_iif = 0; 4129 skb->skb_iif = 0;
4172 skb->ignore_df = 0; 4130 skb->ignore_df = 0;
4173 skb_dst_drop(skb); 4131 skb_dst_drop(skb);
4174 skb->mark = 0; 4132 skb_sender_cpu_clear(skb);
4175 skb->sender_cpu = 0;
4176 skb_init_secmark(skb);
4177 secpath_reset(skb); 4133 secpath_reset(skb);
4178 nf_reset(skb); 4134 nf_reset(skb);
4179 nf_reset_trace(skb); 4135 nf_reset_trace(skb);
4136
4137 if (!xnet)
4138 return;
4139
4140 skb_orphan(skb);
4141 skb->mark = 0;
4180} 4142}
4181EXPORT_SYMBOL_GPL(skb_scrub_packet); 4143EXPORT_SYMBOL_GPL(skb_scrub_packet);
4182 4144