netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next 0/2] inet: prevent skb changes in udp{4|6}_lib_lookup_skb()
@ 2020-11-09 23:13 Eric Dumazet
  2020-11-09 23:13 ` [PATCH net-next 1/2] inet: constify inet_sdif() argument Eric Dumazet
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Eric Dumazet @ 2020-11-09 23:13 UTC (permalink / raw)
  To: David S . Miller, Jakub Kicinski; +Cc: netdev, Eric Dumazet, Eric Dumazet

From: Eric Dumazet <edumazet@google.com>

This came while reviewing Alexander Lobakin patch against UDP GRO:

We want to make sure skb wont be changed by these helpers
while it is owned by GRO stack.

Eric Dumazet (2):
  inet: constify inet_sdif() argument
  inet: udp{4|6}_lib_lookup_skb() skb argument is const

 include/net/ip.h  | 2 +-
 include/net/udp.h | 6 +++---
 net/ipv4/udp.c    | 2 +-
 net/ipv6/udp.c    | 2 +-
 4 files changed, 6 insertions(+), 6 deletions(-)

-- 
2.29.2.222.g5d2a92d10f8-goog


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

* [PATCH net-next 1/2] inet: constify inet_sdif() argument
  2020-11-09 23:13 [PATCH net-next 0/2] inet: prevent skb changes in udp{4|6}_lib_lookup_skb() Eric Dumazet
@ 2020-11-09 23:13 ` Eric Dumazet
  2020-11-09 23:13 ` [PATCH net-next 2/2] inet: udp{4|6}_lib_lookup_skb() skb argument is const Eric Dumazet
  2020-11-11  1:58 ` [PATCH net-next 0/2] inet: prevent skb changes in udp{4|6}_lib_lookup_skb() Jakub Kicinski
  2 siblings, 0 replies; 4+ messages in thread
From: Eric Dumazet @ 2020-11-09 23:13 UTC (permalink / raw)
  To: David S . Miller, Jakub Kicinski
  Cc: netdev, Eric Dumazet, Eric Dumazet, Alexander Lobakin

From: Eric Dumazet <edumazet@google.com>

inet_sdif() does not modify the skb.

This will permit propagating the const qualifier in
udp{4|6}_lib_lookup_skb() functions.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Alexander Lobakin <alobakin@pm.me>
---
 include/net/ip.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/net/ip.h b/include/net/ip.h
index 2d6b985d11ccaa75827b3a15ac3f898d7a193242..e20874059f826eb0f9e899aed556bfbc9c9d71e8 100644
--- a/include/net/ip.h
+++ b/include/net/ip.h
@@ -99,7 +99,7 @@ static inline void ipcm_init_sk(struct ipcm_cookie *ipcm,
 #define PKTINFO_SKB_CB(skb) ((struct in_pktinfo *)((skb)->cb))
 
 /* return enslaved device index if relevant */
-static inline int inet_sdif(struct sk_buff *skb)
+static inline int inet_sdif(const struct sk_buff *skb)
 {
 #if IS_ENABLED(CONFIG_NET_L3_MASTER_DEV)
 	if (skb && ipv4_l3mdev_skb(IPCB(skb)->flags))
-- 
2.29.2.222.g5d2a92d10f8-goog


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

* [PATCH net-next 2/2] inet: udp{4|6}_lib_lookup_skb() skb argument is const
  2020-11-09 23:13 [PATCH net-next 0/2] inet: prevent skb changes in udp{4|6}_lib_lookup_skb() Eric Dumazet
  2020-11-09 23:13 ` [PATCH net-next 1/2] inet: constify inet_sdif() argument Eric Dumazet
@ 2020-11-09 23:13 ` Eric Dumazet
  2020-11-11  1:58 ` [PATCH net-next 0/2] inet: prevent skb changes in udp{4|6}_lib_lookup_skb() Jakub Kicinski
  2 siblings, 0 replies; 4+ messages in thread
From: Eric Dumazet @ 2020-11-09 23:13 UTC (permalink / raw)
  To: David S . Miller, Jakub Kicinski
  Cc: netdev, Eric Dumazet, Eric Dumazet, Alexander Lobakin

From: Eric Dumazet <edumazet@google.com>

The skb is needed only to fetch the keys for the lookup.

Both functions are used from GRO stack, we do not want
accidental modification of the skb.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Alexander Lobakin <alobakin@pm.me>
---
 include/net/udp.h | 6 +++---
 net/ipv4/udp.c    | 2 +-
 net/ipv6/udp.c    | 2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/include/net/udp.h b/include/net/udp.h
index 295d52a73598277dc5071536f777d1a87e7df1d1..877832bed4713a011a514a2f6f522728c8c89e20 100644
--- a/include/net/udp.h
+++ b/include/net/udp.h
@@ -164,7 +164,7 @@ static inline void udp_csum_pull_header(struct sk_buff *skb)
 	UDP_SKB_CB(skb)->cscov -= sizeof(struct udphdr);
 }
 
-typedef struct sock *(*udp_lookup_t)(struct sk_buff *skb, __be16 sport,
+typedef struct sock *(*udp_lookup_t)(const struct sk_buff *skb, __be16 sport,
 				     __be16 dport);
 
 INDIRECT_CALLABLE_DECLARE(struct sk_buff *udp4_gro_receive(struct list_head *,
@@ -313,7 +313,7 @@ struct sock *udp4_lib_lookup(struct net *net, __be32 saddr, __be16 sport,
 struct sock *__udp4_lib_lookup(struct net *net, __be32 saddr, __be16 sport,
 			       __be32 daddr, __be16 dport, int dif, int sdif,
 			       struct udp_table *tbl, struct sk_buff *skb);
-struct sock *udp4_lib_lookup_skb(struct sk_buff *skb,
+struct sock *udp4_lib_lookup_skb(const struct sk_buff *skb,
 				 __be16 sport, __be16 dport);
 struct sock *udp6_lib_lookup(struct net *net,
 			     const struct in6_addr *saddr, __be16 sport,
@@ -324,7 +324,7 @@ struct sock *__udp6_lib_lookup(struct net *net,
 			       const struct in6_addr *daddr, __be16 dport,
 			       int dif, int sdif, struct udp_table *tbl,
 			       struct sk_buff *skb);
-struct sock *udp6_lib_lookup_skb(struct sk_buff *skb,
+struct sock *udp6_lib_lookup_skb(const struct sk_buff *skb,
 				 __be16 sport, __be16 dport);
 
 /* UDP uses skb->dev_scratch to cache as much information as possible and avoid
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index ca04a8a35e52dbcff50b03da2710726dc6ee98bd..8c9f08343e171ba9b78ebe7bfe22e6508ab15c42 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -541,7 +541,7 @@ static inline struct sock *__udp4_lib_lookup_skb(struct sk_buff *skb,
 				 inet_sdif(skb), udptable, skb);
 }
 
-struct sock *udp4_lib_lookup_skb(struct sk_buff *skb,
+struct sock *udp4_lib_lookup_skb(const struct sk_buff *skb,
 				 __be16 sport, __be16 dport)
 {
 	const struct iphdr *iph = ip_hdr(skb);
diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
index cde9b8874d4bce4cdbee557d89a0be0ddf3f87df..c32f50d2a0694580426ea71e52a1cee23ed07045 100644
--- a/net/ipv6/udp.c
+++ b/net/ipv6/udp.c
@@ -276,7 +276,7 @@ static struct sock *__udp6_lib_lookup_skb(struct sk_buff *skb,
 				 inet6_sdif(skb), udptable, skb);
 }
 
-struct sock *udp6_lib_lookup_skb(struct sk_buff *skb,
+struct sock *udp6_lib_lookup_skb(const struct sk_buff *skb,
 				 __be16 sport, __be16 dport)
 {
 	const struct ipv6hdr *iph = ipv6_hdr(skb);
-- 
2.29.2.222.g5d2a92d10f8-goog


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

* Re: [PATCH net-next 0/2] inet: prevent skb changes in udp{4|6}_lib_lookup_skb()
  2020-11-09 23:13 [PATCH net-next 0/2] inet: prevent skb changes in udp{4|6}_lib_lookup_skb() Eric Dumazet
  2020-11-09 23:13 ` [PATCH net-next 1/2] inet: constify inet_sdif() argument Eric Dumazet
  2020-11-09 23:13 ` [PATCH net-next 2/2] inet: udp{4|6}_lib_lookup_skb() skb argument is const Eric Dumazet
@ 2020-11-11  1:58 ` Jakub Kicinski
  2 siblings, 0 replies; 4+ messages in thread
From: Jakub Kicinski @ 2020-11-11  1:58 UTC (permalink / raw)
  To: Eric Dumazet; +Cc: David S . Miller, netdev, Eric Dumazet

On Mon,  9 Nov 2020 15:13:47 -0800 Eric Dumazet wrote:
> From: Eric Dumazet <edumazet@google.com>
> 
> This came while reviewing Alexander Lobakin patch against UDP GRO:
> 
> We want to make sure skb wont be changed by these helpers
> while it is owned by GRO stack.

Applied, thank you!

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

end of thread, other threads:[~2020-11-11  1:58 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-09 23:13 [PATCH net-next 0/2] inet: prevent skb changes in udp{4|6}_lib_lookup_skb() Eric Dumazet
2020-11-09 23:13 ` [PATCH net-next 1/2] inet: constify inet_sdif() argument Eric Dumazet
2020-11-09 23:13 ` [PATCH net-next 2/2] inet: udp{4|6}_lib_lookup_skb() skb argument is const Eric Dumazet
2020-11-11  1:58 ` [PATCH net-next 0/2] inet: prevent skb changes in udp{4|6}_lib_lookup_skb() Jakub Kicinski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).