All of lore.kernel.org
 help / color / mirror / Atom feed
* Question about inet_rtm_getroute_build_skb()
@ 2021-08-27  1:16 Eric Dumazet
  2021-08-27  4:37 ` David Ahern
  0 siblings, 1 reply; 4+ messages in thread
From: Eric Dumazet @ 2021-08-27  1:16 UTC (permalink / raw)
  To: Roopa Prabhu, Networking

Hi Roopa

I noticed inet_rtm_getroute_build_skb() has this endian issue 
when building an UDP header.

Would the following fix break user space ?

Thanks.

diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index a6f20ee3533554b210d27c4ab6637ca7a05b148b..50133b935f868c2ae9474eea027a0ad864a43936 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -3170,7 +3170,7 @@ static struct sk_buff *inet_rtm_getroute_build_skb(__be32 src, __be32 dst,
                udph = skb_put_zero(skb, sizeof(struct udphdr));
                udph->source = sport;
                udph->dest = dport;
-               udph->len = sizeof(struct udphdr);
+               udph->len = htons(sizeof(struct udphdr));
                udph->check = 0;
                break;
        }

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: Question about inet_rtm_getroute_build_skb()
  2021-08-27  1:16 Question about inet_rtm_getroute_build_skb() Eric Dumazet
@ 2021-08-27  4:37 ` David Ahern
  2021-08-27 15:09   ` Eric Dumazet
  0 siblings, 1 reply; 4+ messages in thread
From: David Ahern @ 2021-08-27  4:37 UTC (permalink / raw)
  To: Eric Dumazet, Networking, Roopa Prabhu

On 8/26/21 6:16 PM, Eric Dumazet wrote:
> Hi Roopa
> 
> I noticed inet_rtm_getroute_build_skb() has this endian issue 
> when building an UDP header.
> 
> Would the following fix break user space ?

I do not see how. As I recall this is only for going through
ip_route_input_rcu and ip_route_output_key_hash_rcu and a call to
fib4_rules_early_flow_dissect.

> 
> Thanks.
> 
> diff --git a/net/ipv4/route.c b/net/ipv4/route.c
> index a6f20ee3533554b210d27c4ab6637ca7a05b148b..50133b935f868c2ae9474eea027a0ad864a43936 100644
> --- a/net/ipv4/route.c
> +++ b/net/ipv4/route.c
> @@ -3170,7 +3170,7 @@ static struct sk_buff *inet_rtm_getroute_build_skb(__be32 src, __be32 dst,
>                 udph = skb_put_zero(skb, sizeof(struct udphdr));
>                 udph->source = sport;
>                 udph->dest = dport;
> -               udph->len = sizeof(struct udphdr);
> +               udph->len = htons(sizeof(struct udphdr));
>                 udph->check = 0;
>                 break;
>         }
> 


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Question about inet_rtm_getroute_build_skb()
  2021-08-27  4:37 ` David Ahern
@ 2021-08-27 15:09   ` Eric Dumazet
  2021-08-27 16:46     ` David Ahern
  0 siblings, 1 reply; 4+ messages in thread
From: Eric Dumazet @ 2021-08-27 15:09 UTC (permalink / raw)
  To: David Ahern, Eric Dumazet, Networking, Roopa Prabhu



On 8/26/21 9:37 PM, David Ahern wrote:
> On 8/26/21 6:16 PM, Eric Dumazet wrote:
>> Hi Roopa
>>
>> I noticed inet_rtm_getroute_build_skb() has this endian issue 
>> when building an UDP header.
>>
>> Would the following fix break user space ?
> 
> I do not see how. As I recall this is only for going through
> ip_route_input_rcu and ip_route_output_key_hash_rcu and a call to
> fib4_rules_early_flow_dissect.
> 

Ah, nice !

Could we add a test for this feature ?
I could not really figure out reading the commit changelog how this stuff was used.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Question about inet_rtm_getroute_build_skb()
  2021-08-27 15:09   ` Eric Dumazet
@ 2021-08-27 16:46     ` David Ahern
  0 siblings, 0 replies; 4+ messages in thread
From: David Ahern @ 2021-08-27 16:46 UTC (permalink / raw)
  To: Eric Dumazet, Networking, Roopa Prabhu

On 8/27/21 8:09 AM, Eric Dumazet wrote:
> 
> 
> On 8/26/21 9:37 PM, David Ahern wrote:
>> On 8/26/21 6:16 PM, Eric Dumazet wrote:
>>> Hi Roopa
>>>
>>> I noticed inet_rtm_getroute_build_skb() has this endian issue 
>>> when building an UDP header.
>>>
>>> Would the following fix break user space ?
>>
>> I do not see how. As I recall this is only for going through
>> ip_route_input_rcu and ip_route_output_key_hash_rcu and a call to
>> fib4_rules_early_flow_dissect.
>>
> 
> Ah, nice !
> 
> Could we add a test for this feature ?
> I could not really figure out reading the commit changelog how this stuff was used.
> 

tools/testing/selftests/net/fib_rule_tests.sh

I do not see the udp variant, so yes, those should be added.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-08-27 16:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-27  1:16 Question about inet_rtm_getroute_build_skb() Eric Dumazet
2021-08-27  4:37 ` David Ahern
2021-08-27 15:09   ` Eric Dumazet
2021-08-27 16:46     ` David Ahern

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.