All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jonas Bonn <jonas@norrbonn.se>
To: netdev@vger.kernel.org
Cc: pablo@netfilter.org, laforge@gnumonks.org,
	Jonas Bonn <jonas@norrbonn.se>
Subject: [PATCH net-next v2 07/12] gtp: use ephemeral source port
Date: Fri, 11 Dec 2020 13:26:07 +0100	[thread overview]
Message-ID: <20201211122612.869225-8-jonas@norrbonn.se> (raw)
In-Reply-To: <20201211122612.869225-1-jonas@norrbonn.se>

All GTP traffic is currently sent from the same source port.  This makes
everything look like one big flow which is difficult to balance across
network resources.

From 3GPP TS 29.281:
"...the UDP Source Port or the Flow Label field... should be set dynamically
by the sending GTP-U entity to help balancing the load in the transport
network."

Signed-off-by: Jonas Bonn <jonas@norrbonn.se>
---
 drivers/net/gtp.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/net/gtp.c b/drivers/net/gtp.c
index 4a3a52970856..236ebbcb37bf 100644
--- a/drivers/net/gtp.c
+++ b/drivers/net/gtp.c
@@ -477,7 +477,7 @@ static int gtp_xmit_ip4(struct sk_buff *skb, struct net_device *dev)
 	__be32 saddr;
 	struct iphdr *iph;
 	int headroom;
-	__be16 port;
+	__be16 sport, port;
 	int r;
 
 	/* Read the IP destination address and resolve the PDP context.
@@ -527,6 +527,10 @@ static int gtp_xmit_ip4(struct sk_buff *skb, struct net_device *dev)
 		return -EMSGSIZE;
 	}
 
+	sport = udp_flow_src_port(sock_net(pctx->sk), skb,
+			0, USHRT_MAX,
+			true);
+
 	/* Ensure there is sufficient headroom. */
 	r = skb_cow_head(skb, headroom);
 	if (unlikely(r))
@@ -545,7 +549,7 @@ static int gtp_xmit_ip4(struct sk_buff *skb, struct net_device *dev)
 			    iph->tos,
 			    ip4_dst_hoplimit(&rt->dst),
 			    0,
-			    port, port,
+			    sport, port,
 			    !net_eq(sock_net(pctx->sk),
 				    dev_net(pctx->dev)),
 			    false);
-- 
2.27.0


  parent reply	other threads:[~2020-12-11 12:29 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-11 12:26 [PATCH net-next v2 00/12] gtp: IPv6 support Jonas Bonn
2020-12-11 12:26 ` [PATCH net-next v2 01/12] gtp: set initial MTU Jonas Bonn
2020-12-12  9:38   ` Harald Welte
2020-12-11 12:26 ` [PATCH net-next v2 02/12] gtp: include role in link info Jonas Bonn
2020-12-12  9:40   ` Harald Welte
2020-12-11 12:26 ` [PATCH net-next v2 03/12] gtp: really check namespaces before xmit Jonas Bonn
2020-12-12  9:41   ` Harald Welte
2020-12-11 12:26 ` [PATCH net-next v2 04/12] gtp: drop unnecessary call to skb_dst_drop Jonas Bonn
2020-12-12  9:50   ` Harald Welte
2020-12-12 11:38     ` Jonas Bonn
2020-12-11 12:26 ` [PATCH net-next v2 05/12] gtp: set device type Jonas Bonn
2020-12-12  9:51   ` Harald Welte
2020-12-11 12:26 ` [PATCH net-next v2 06/12] gtp: rework IPv4 functionality Jonas Bonn
2020-12-11 12:26 ` Jonas Bonn [this message]
2020-12-12  5:35   ` [PATCH net-next v2 07/12] gtp: use ephemeral source port Pravin Shelar
2020-12-12  7:49     ` Jonas Bonn
2020-12-12 10:07   ` Harald Welte
2020-12-12 13:40     ` Jonas Bonn
2020-12-11 12:26 ` [PATCH net-next v2 08/12] gtp: set dev features to enable GSO Jonas Bonn
2020-12-12  5:31   ` Pravin Shelar
2020-12-12  7:50     ` Jonas Bonn
2020-12-13 18:25       ` Pravin Shelar
2020-12-11 12:26 ` [PATCH net-next v2 09/12] gtp: support GRO Jonas Bonn
2020-12-11 15:43   ` kernel test robot
2020-12-11 15:43     ` kernel test robot
2020-12-11 12:26 ` [PATCH net-next v2 10/12] gtp: add IPv6 support Jonas Bonn
2020-12-12  5:51   ` Pravin Shelar
2020-12-12  7:05     ` Jonas Bonn
2020-12-12 11:05       ` Harald Welte
2020-12-12 11:22   ` Harald Welte
2020-12-12 13:59     ` Jonas Bonn
2020-12-11 12:26 ` [PATCH net-next v2 11/12] gtp: netlink update for ipv6 Jonas Bonn
2020-12-12 11:25   ` Harald Welte
2020-12-11 12:26 ` [PATCH net-next v2 12/12] gtp: add dst_cache to tunnels Jonas Bonn
2020-12-11 17:25   ` kernel test robot
2020-12-11 17:25     ` kernel test robot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201211122612.869225-8-jonas@norrbonn.se \
    --to=jonas@norrbonn.se \
    --cc=laforge@gnumonks.org \
    --cc=netdev@vger.kernel.org \
    --cc=pablo@netfilter.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.