aboutsummaryrefslogtreecommitdiffstats
path: root/net/core/skbuff.c
diff options
context:
space:
mode:
authorIngo Molnar <mingo@kernel.org>2015-03-05 14:52:18 -0500
committerIngo Molnar <mingo@kernel.org>2015-03-05 14:52:18 -0500
commit33ca8a53f262b4af40611bea331b8c87d133af72 (patch)
treed6468c820a556c4915bcb5b761204a0fb19e8225 /net/core/skbuff.c
parentdb2dcb4f91d5fec5c346a82c309187ee821e2495 (diff)
parent13a7a6ac0a11197edcd0f756a035f472b42cdf8b (diff)
Merge tag 'v4.0-rc2' into irq/core, to refresh the tree before applying new changes
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'net/core/skbuff.c')
-rw-r--r--net/core/skbuff.c59
1 files changed, 42 insertions, 17 deletions
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 395c15b82087..88c613eab142 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -74,6 +74,8 @@
74#include <asm/uaccess.h> 74#include <asm/uaccess.h>
75#include <trace/events/skb.h> 75#include <trace/events/skb.h>
76#include <linux/highmem.h> 76#include <linux/highmem.h>
77#include <linux/capability.h>
78#include <linux/user_namespace.h>
77 79
78struct kmem_cache *skbuff_head_cache __read_mostly; 80struct kmem_cache *skbuff_head_cache __read_mostly;
79static struct kmem_cache *skbuff_fclone_cache __read_mostly; 81static struct kmem_cache *skbuff_fclone_cache __read_mostly;
@@ -677,13 +679,6 @@ static void skb_release_head_state(struct sk_buff *skb)
677#if IS_ENABLED(CONFIG_BRIDGE_NETFILTER) 679#if IS_ENABLED(CONFIG_BRIDGE_NETFILTER)
678 nf_bridge_put(skb->nf_bridge); 680 nf_bridge_put(skb->nf_bridge);
679#endif 681#endif
680/* XXX: IS this still necessary? - JHS */
681#ifdef CONFIG_NET_SCHED
682 skb->tc_index = 0;
683#ifdef CONFIG_NET_CLS_ACT
684 skb->tc_verd = 0;
685#endif
686#endif
687} 682}
688 683
689/* Free everything but the sk_buff shell. */ 684/* Free everything but the sk_buff shell. */
@@ -830,6 +825,9 @@ static void __copy_skb_header(struct sk_buff *new, const struct sk_buff *old)
830#ifdef CONFIG_NET_RX_BUSY_POLL 825#ifdef CONFIG_NET_RX_BUSY_POLL
831 CHECK_SKB_FIELD(napi_id); 826 CHECK_SKB_FIELD(napi_id);
832#endif 827#endif
828#ifdef CONFIG_XPS
829 CHECK_SKB_FIELD(sender_cpu);
830#endif
833#ifdef CONFIG_NET_SCHED 831#ifdef CONFIG_NET_SCHED
834 CHECK_SKB_FIELD(tc_index); 832 CHECK_SKB_FIELD(tc_index);
835#ifdef CONFIG_NET_CLS_ACT 833#ifdef CONFIG_NET_CLS_ACT
@@ -3697,11 +3695,28 @@ static void __skb_complete_tx_timestamp(struct sk_buff *skb,
3697 kfree_skb(skb); 3695 kfree_skb(skb);
3698} 3696}
3699 3697
3698static bool skb_may_tx_timestamp(struct sock *sk, bool tsonly)
3699{
3700 bool ret;
3701
3702 if (likely(sysctl_tstamp_allow_data || tsonly))
3703 return true;
3704
3705 read_lock_bh(&sk->sk_callback_lock);
3706 ret = sk->sk_socket && sk->sk_socket->file &&
3707 file_ns_capable(sk->sk_socket->file, &init_user_ns, CAP_NET_RAW);
3708 read_unlock_bh(&sk->sk_callback_lock);
3709 return ret;
3710}
3711
3700void skb_complete_tx_timestamp(struct sk_buff *skb, 3712void skb_complete_tx_timestamp(struct sk_buff *skb,
3701 struct skb_shared_hwtstamps *hwtstamps) 3713 struct skb_shared_hwtstamps *hwtstamps)
3702{ 3714{
3703 struct sock *sk = skb->sk; 3715 struct sock *sk = skb->sk;
3704 3716
3717 if (!skb_may_tx_timestamp(sk, false))
3718 return;
3719
3705 /* take a reference to prevent skb_orphan() from freeing the socket */ 3720 /* take a reference to prevent skb_orphan() from freeing the socket */
3706 sock_hold(sk); 3721 sock_hold(sk);
3707 3722
@@ -3717,19 +3732,28 @@ void __skb_tstamp_tx(struct sk_buff *orig_skb,
3717 struct sock *sk, int tstype) 3732 struct sock *sk, int tstype)
3718{ 3733{
3719 struct sk_buff *skb; 3734 struct sk_buff *skb;
3735 bool tsonly = sk->sk_tsflags & SOF_TIMESTAMPING_OPT_TSONLY;
3720 3736
3721 if (!sk) 3737 if (!sk || !skb_may_tx_timestamp(sk, tsonly))
3722 return; 3738 return;
3723 3739
3724 if (hwtstamps) 3740 if (tsonly)
3725 *skb_hwtstamps(orig_skb) = *hwtstamps; 3741 skb = alloc_skb(0, GFP_ATOMIC);
3726 else 3742 else
3727 orig_skb->tstamp = ktime_get_real(); 3743 skb = skb_clone(orig_skb, GFP_ATOMIC);
3728
3729 skb = skb_clone(orig_skb, GFP_ATOMIC);
3730 if (!skb) 3744 if (!skb)
3731 return; 3745 return;
3732 3746
3747 if (tsonly) {
3748 skb_shinfo(skb)->tx_flags = skb_shinfo(orig_skb)->tx_flags;
3749 skb_shinfo(skb)->tskey = skb_shinfo(orig_skb)->tskey;
3750 }
3751
3752 if (hwtstamps)
3753 *skb_hwtstamps(skb) = *hwtstamps;
3754 else
3755 skb->tstamp = ktime_get_real();
3756
3733 __skb_complete_tx_timestamp(skb, sk, tstype); 3757 __skb_complete_tx_timestamp(skb, sk, tstype);
3734} 3758}
3735EXPORT_SYMBOL_GPL(__skb_tstamp_tx); 3759EXPORT_SYMBOL_GPL(__skb_tstamp_tx);
@@ -4148,6 +4172,7 @@ void skb_scrub_packet(struct sk_buff *skb, bool xnet)
4148 skb->ignore_df = 0; 4172 skb->ignore_df = 0;
4149 skb_dst_drop(skb); 4173 skb_dst_drop(skb);
4150 skb->mark = 0; 4174 skb->mark = 0;
4175 skb->sender_cpu = 0;
4151 skb_init_secmark(skb); 4176 skb_init_secmark(skb);
4152 secpath_reset(skb); 4177 secpath_reset(skb);
4153 nf_reset(skb); 4178 nf_reset(skb);
@@ -4204,7 +4229,7 @@ struct sk_buff *skb_vlan_untag(struct sk_buff *skb)
4204 struct vlan_hdr *vhdr; 4229 struct vlan_hdr *vhdr;
4205 u16 vlan_tci; 4230 u16 vlan_tci;
4206 4231
4207 if (unlikely(vlan_tx_tag_present(skb))) { 4232 if (unlikely(skb_vlan_tag_present(skb))) {
4208 /* vlan_tci is already set-up so leave this for another time */ 4233 /* vlan_tci is already set-up so leave this for another time */
4209 return skb; 4234 return skb;
4210 } 4235 }
@@ -4290,7 +4315,7 @@ int skb_vlan_pop(struct sk_buff *skb)
4290 __be16 vlan_proto; 4315 __be16 vlan_proto;
4291 int err; 4316 int err;
4292 4317
4293 if (likely(vlan_tx_tag_present(skb))) { 4318 if (likely(skb_vlan_tag_present(skb))) {
4294 skb->vlan_tci = 0; 4319 skb->vlan_tci = 0;
4295 } else { 4320 } else {
4296 if (unlikely((skb->protocol != htons(ETH_P_8021Q) && 4321 if (unlikely((skb->protocol != htons(ETH_P_8021Q) &&
@@ -4320,7 +4345,7 @@ EXPORT_SYMBOL(skb_vlan_pop);
4320 4345
4321int skb_vlan_push(struct sk_buff *skb, __be16 vlan_proto, u16 vlan_tci) 4346int skb_vlan_push(struct sk_buff *skb, __be16 vlan_proto, u16 vlan_tci)
4322{ 4347{
4323 if (vlan_tx_tag_present(skb)) { 4348 if (skb_vlan_tag_present(skb)) {
4324 unsigned int offset = skb->data - skb_mac_header(skb); 4349 unsigned int offset = skb->data - skb_mac_header(skb);
4325 int err; 4350 int err;
4326 4351
@@ -4330,7 +4355,7 @@ int skb_vlan_push(struct sk_buff *skb, __be16 vlan_proto, u16 vlan_tci)
4330 */ 4355 */
4331 __skb_push(skb, offset); 4356 __skb_push(skb, offset);
4332 err = __vlan_insert_tag(skb, skb->vlan_proto, 4357 err = __vlan_insert_tag(skb, skb->vlan_proto,
4333 vlan_tx_tag_get(skb)); 4358 skb_vlan_tag_get(skb));
4334 if (err) 4359 if (err)
4335 return err; 4360 return err;
4336 skb->protocol = skb->vlan_proto; 4361 skb->protocol = skb->vlan_proto;