diff mbox

[net-next] ipv6: Initial skb->dev and skb->protocol in ip6_output

Message ID 1497035168-9093-1-git-send-email-chenbofeng.kernel@gmail.com
State Accepted, archived
Delegated to: David Miller
Headers show

Commit Message

Chenbo Feng June 9, 2017, 7:06 p.m. UTC
From: Chenbo Feng <fengc@google.com>

Move the initialization of skb->dev and skb->protocol from
ip6_finish_output2 to ip6_output. This can make the skb->dev and
skb->protocol information avalaible to the CGROUP eBPF filter.

Signed-off-by: Chenbo Feng <fengc@google.com>
Acked-by: Eric Dumazet <edumazet@google.com>
---
 net/ipv6/ip6_output.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

David Miller June 9, 2017, 7:08 p.m. UTC | #1
From: Chenbo Feng <chenbofeng.kernel@gmail.com>
Date: Fri,  9 Jun 2017 12:06:07 -0700

> From: Chenbo Feng <fengc@google.com>
> 
> Move the initialization of skb->dev and skb->protocol from
> ip6_finish_output2 to ip6_output. This can make the skb->dev and
> skb->protocol information avalaible to the CGROUP eBPF filter.
> 
> Signed-off-by: Chenbo Feng <fengc@google.com>
> Acked-by: Eric Dumazet <edumazet@google.com>

Applied, thanks.

This makes ipv6 consistent with ipv4.

I am surprised this wasn't noticed, for example, in netfilter.
Chenbo Feng June 9, 2017, 7:13 p.m. UTC | #2
On 06/09/2017 12:08 PM, David Miller wrote:
> From: Chenbo Feng <chenbofeng.kernel@gmail.com>
> Date: Fri,  9 Jun 2017 12:06:07 -0700
>
>> From: Chenbo Feng <fengc@google.com>
>>
>> Move the initialization of skb->dev and skb->protocol from
>> ip6_finish_output2 to ip6_output. This can make the skb->dev and
>> skb->protocol information avalaible to the CGROUP eBPF filter.
>>
>> Signed-off-by: Chenbo Feng <fengc@google.com>
>> Acked-by: Eric Dumazet <edumazet@google.com>
> Applied, thanks.
>
> This makes ipv6 consistent with ipv4.
>
> I am surprised this wasn't noticed, for example, in netfilter.
> .
>
Hi David,

This patch is still under working since it may have problem with 
ip_fragment() call, did you applied it already? Should I send a revert 
patch to you then?

Chenbo Feng
Bjørn Mork June 9, 2017, 7:24 p.m. UTC | #3
Chenbo Feng <chenbofeng.kernel@gmail.com> writes:

> This patch is still under working since it may have problem with
> ip_fragment() call, did you applied it already? Should I send a revert
> patch to you then?

It does? I initially thought so too, but looking closer I believe the
ip6_copy_metadata() calls in ip6_fragment() takes care of it.



Bjørn
David Miller June 9, 2017, 7:39 p.m. UTC | #4
From: Chenbo Feng <fengc@google.com>
Date: Fri, 9 Jun 2017 12:08:39 -0700

> Sorry, this is the wrong patch, please ignore it.

:-/ already applied it.

You must now send a relative fixup patch.
David Miller June 9, 2017, 7:39 p.m. UTC | #5
From: Chenbo Feng <chenbofeng.kernel@gmail.com>
Date: Fri, 9 Jun 2017 12:13:57 -0700

> 
> 
> On 06/09/2017 12:08 PM, David Miller wrote:
>> From: Chenbo Feng <chenbofeng.kernel@gmail.com>
>> Date: Fri,  9 Jun 2017 12:06:07 -0700
>>
>>> From: Chenbo Feng <fengc@google.com>
>>>
>>> Move the initialization of skb->dev and skb->protocol from
>>> ip6_finish_output2 to ip6_output. This can make the skb->dev and
>>> skb->protocol information avalaible to the CGROUP eBPF filter.
>>>
>>> Signed-off-by: Chenbo Feng <fengc@google.com>
>>> Acked-by: Eric Dumazet <edumazet@google.com>
>> Applied, thanks.
>>
>> This makes ipv6 consistent with ipv4.
>>
>> I am surprised this wasn't noticed, for example, in netfilter.
>> .
>>
> Hi David,
> 
> This patch is still under working since it may have problem with
> ip_fragment() call, did you applied it already? Should I send a revert
> patch to you then?

A revert is necessary or a relative fixup.

Thank you.
Chenbo Feng June 9, 2017, 7:45 p.m. UTC | #6
On 06/09/2017 12:24 PM, Bjørn Mork wrote:
> Chenbo Feng <chenbofeng.kernel@gmail.com> writes:
>
>> This patch is still under working since it may have problem with
>> ip_fragment() call, did you applied it already? Should I send a revert
>> patch to you then?
> It does? I initially thought so too, but looking closer I believe the
> ip6_copy_metadata() calls in ip6_fragment() takes care of it.
>
>
>
> Bjørn
>
At least in the fail_toobig code path of ip_fragment() call, skb->dev 
get assigned again. It seems to be redundant with this patch or it will 
rewrite the skb->dev field. I will revert this one and upload again 
after I have a proper handle for that.
Eric Dumazet June 9, 2017, 9:11 p.m. UTC | #7
On Fri, Jun 9, 2017 at 12:06 PM, Chenbo Feng
<chenbofeng.kernel@gmail.com> wrote:
> From: Chenbo Feng <fengc@google.com>
>
> Move the initialization of skb->dev and skb->protocol from
> ip6_finish_output2 to ip6_output. This can make the skb->dev and
> skb->protocol information avalaible to the CGROUP eBPF filter.
>
> Signed-off-by: Chenbo Feng <fengc@google.com>
> Acked-by: Eric Dumazet <edumazet@google.com>
> ---

Arg, you mixed my Acked-by for your other patch :/
Chenbo Feng June 9, 2017, 11:12 p.m. UTC | #8
On 06/09/2017 12:39 PM, David Miller wrote:
> From: Chenbo Feng <chenbofeng.kernel@gmail.com>
> Date: Fri, 9 Jun 2017 12:13:57 -0700
>
>>
>> On 06/09/2017 12:08 PM, David Miller wrote:
>>> From: Chenbo Feng <chenbofeng.kernel@gmail.com>
>>> Date: Fri,  9 Jun 2017 12:06:07 -0700
>>>
>>>> From: Chenbo Feng <fengc@google.com>
>>>>
>>>> Move the initialization of skb->dev and skb->protocol from
>>>> ip6_finish_output2 to ip6_output. This can make the skb->dev and
>>>> skb->protocol information avalaible to the CGROUP eBPF filter.
>>>>
>>>> Signed-off-by: Chenbo Feng <fengc@google.com>
>>>> Acked-by: Eric Dumazet <edumazet@google.com>
>>> Applied, thanks.
>>>
>>> This makes ipv6 consistent with ipv4.
>>>
>>> I am surprised this wasn't noticed, for example, in netfilter.
>>> .
>>>
>> Hi David,
>>
>> This patch is still under working since it may have problem with
>> ip_fragment() call, did you applied it already? Should I send a revert
>> patch to you then?
> A revert is necessary or a relative fixup.
>
> Thank you.
>
Hi David,

The revert is uploaded here: http://patchwork.ozlabs.org/patch/774136/

Thanks and sorry for the trouble caused

Chenbo Feng
Eric Dumazet June 10, 2017, 2:56 p.m. UTC | #9
On Fri, 2017-06-09 at 21:24 +0200, Bjørn Mork wrote:
> Chenbo Feng <chenbofeng.kernel@gmail.com> writes:
> 
> > This patch is still under working since it may have problem with
> > ip_fragment() call, did you applied it already? Should I send a revert
> > patch to you then?
> 
> It does? I initially thought so too, but looking closer I believe the
> ip6_copy_metadata() calls in ip6_fragment() takes care of it.

Indeed, this should be fine.
diff mbox

Patch

diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
index bf8a58a..02cd44f 100644
--- a/net/ipv6/ip6_output.c
+++ b/net/ipv6/ip6_output.c
@@ -67,9 +67,6 @@  static int ip6_finish_output2(struct net *net, struct sock *sk, struct sk_buff *
 	struct in6_addr *nexthop;
 	int ret;
 
-	skb->protocol = htons(ETH_P_IPV6);
-	skb->dev = dev;
-
 	if (ipv6_addr_is_multicast(&ipv6_hdr(skb)->daddr)) {
 		struct inet6_dev *idev = ip6_dst_idev(skb_dst(skb));
 
@@ -154,6 +151,9 @@  int ip6_output(struct net *net, struct sock *sk, struct sk_buff *skb)
 	struct net_device *dev = skb_dst(skb)->dev;
 	struct inet6_dev *idev = ip6_dst_idev(skb_dst(skb));
 
+	skb->protocol = htons(ETH_P_IPV6);
+	skb->dev = dev;
+
 	if (unlikely(idev->cnf.disable_ipv6)) {
 		IP6_INC_STATS(net, idev, IPSTATS_MIB_OUTDISCARDS);
 		kfree_skb(skb);