linux-sctp.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next 00/15] sctp: Implement RFC6951: UDP Encapsulation of SCTP
@ 2020-09-29 13:48 Xin Long
  2020-09-29 13:48 ` Xin Long
                   ` (3 more replies)
  0 siblings, 4 replies; 82+ messages in thread
From: Xin Long @ 2020-09-29 13:48 UTC (permalink / raw)
  To: network dev, linux-sctp
  Cc: Marcelo Ricardo Leitner, Neil Horman, Michael Tuexen, Tom Herbert, davem

Description From the RFC:

   The Main Reasons:

   o  To allow SCTP traffic to pass through legacy NATs, which do not
      provide native SCTP support as specified in [BEHAVE] and
      [NATSUPP].

   o  To allow SCTP to be implemented on hosts that do not provide
      direct access to the IP layer.  In particular, applications can
      use their own SCTP implementation if the operating system does not
      provide one.

   Implementation Notes:

   UDP-encapsulated SCTP is normally communicated between SCTP stacks
   using the IANA-assigned UDP port number 9899 (sctp-tunneling) on both
   ends.  There are circumstances where other ports may be used on
   either end, and it might be required to use ports other than the
   registered port.

   Each SCTP stack uses a single local UDP encapsulation port number as
   the destination port for all its incoming SCTP packets, this greatly
   simplifies implementation design.

   An SCTP implementation supporting UDP encapsulation MUST maintain a
   remote UDP encapsulation port number per destination address for each
   SCTP association.  Again, because the remote stack may be using ports
   other than the well-known port, each port may be different from each
   stack.  However, because of remapping of ports by NATs, the remote
   ports associated with different remote IP addresses may not be
   identical, even if they are associated with the same stack.

   Because the well-known port might not be used, implementations need
   to allow other port numbers to be specified as a local or remote UDP
   encapsulation port number through APIs.

Patches:

   This patchset is using the udp4/6 tunnel APIs to implement the UDP
   Encapsulation of SCTP with not much change in SCTP protocol stack
   and with all current SCTP features keeped in Linux Kernel.

   1 - 4: Fix some UDP issues that may be triggered by SCTP over UDP.
   5 - 7: Process incoming UDP encapsulated packets and ICMP packets.
   8 -10: Remote encap port's update by sysctl, sockopt and packets.
   11-14: Process outgoing pakects with UDP encapsulated and its GSO.
      15: Enable this feature.

Tests:

  - lksctp-tools/src/func_tests with UDP Encapsulation enabled/disabled:

      Both make v4test and v6test passed.

  - sctp-tests with UDP Encapsulation enabled/disabled:

      repeatability/procdumps/sctpdiag/gsomtuchange/extoverflow/
      sctphashtable passed. Others failed as expected due to those
      "iptables -p sctp" rules.

  - netperf on lo/netns/virtio_net, with gso enabled/disabled and
    with ip_checksum enabled/disabled, with UDP Encapsulation
    enabled/disabled:

      No clear performance dropped.

Xin Long (15):
  udp: check udp sock encap_type in __udp_lib_err
  udp6: move the mss check after udp gso tunnel processing
  udp: do checksum properly in skb_udp_tunnel_segment
  udp: support sctp over udp in skb_udp_tunnel_segment
  sctp: create udp4 sock and add its encap_rcv
  sctp: create udp6 sock and set its encap_rcv
  sctp: add encap_err_lookup for udp encap socks
  sctp: add encap_port for netns sock asoc and transport
  sctp: add SCTP_REMOTE_UDP_ENCAPS_PORT sockopt
  sctp: allow changing transport encap_port by peer packets
  sctp: add udphdr to overhead when udp_port is set
  sctp: call sk_setup_caps in sctp_packet_transmit instead
  sctp: support for sending packet over udp4 sock
  sctp: support for sending packet over udp6 sock
  sctp: enable udp tunneling socks

 include/net/netns/sctp.h     |   8 +++
 include/net/sctp/constants.h |   2 +
 include/net/sctp/sctp.h      |   9 ++-
 include/net/sctp/sm.h        |   1 +
 include/net/sctp/structs.h   |  13 ++--
 include/uapi/linux/sctp.h    |   7 ++
 net/ipv4/udp.c               |   2 +-
 net/ipv4/udp_offload.c       |  16 +++--
 net/ipv6/udp.c               |   2 +-
 net/ipv6/udp_offload.c       | 154 +++++++++++++++++++++----------------------
 net/sctp/associola.c         |   4 ++
 net/sctp/ipv6.c              |  48 ++++++++++----
 net/sctp/output.c            |  22 +++----
 net/sctp/protocol.c          | 145 ++++++++++++++++++++++++++++++++++++----
 net/sctp/sm_make_chunk.c     |   1 +
 net/sctp/sm_statefuns.c      |   2 +
 net/sctp/socket.c            | 111 +++++++++++++++++++++++++++++++
 net/sctp/sysctl.c            |  53 +++++++++++++++
 18 files changed, 471 insertions(+), 129 deletions(-)

-- 
2.1.0

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

* [PATCH net-next 00/15] sctp: Implement RFC6951: UDP Encapsulation of SCTP
  2020-09-29 13:48 [PATCH net-next 00/15] sctp: Implement RFC6951: UDP Encapsulation of SCTP Xin Long
@ 2020-09-29 13:48 ` Xin Long
  2020-09-29 13:48 ` [PATCH net-next 01/15] udp: check udp sock encap_type in __udp_lib_err Xin Long
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 82+ messages in thread
From: Xin Long @ 2020-09-29 13:48 UTC (permalink / raw)
  To: network dev, linux-sctp
  Cc: Marcelo Ricardo Leitner, Neil Horman, Michael Tuexen, Tom Herbert, davem

Description From the RFC:

   The Main Reasons:

   o  To allow SCTP traffic to pass through legacy NATs, which do not
      provide native SCTP support as specified in [BEHAVE] and
      [NATSUPP].

   o  To allow SCTP to be implemented on hosts that do not provide
      direct access to the IP layer.  In particular, applications can
      use their own SCTP implementation if the operating system does not
      provide one.

   Implementation Notes:

   UDP-encapsulated SCTP is normally communicated between SCTP stacks
   using the IANA-assigned UDP port number 9899 (sctp-tunneling) on both
   ends.  There are circumstances where other ports may be used on
   either end, and it might be required to use ports other than the
   registered port.

   Each SCTP stack uses a single local UDP encapsulation port number as
   the destination port for all its incoming SCTP packets, this greatly
   simplifies implementation design.

   An SCTP implementation supporting UDP encapsulation MUST maintain a
   remote UDP encapsulation port number per destination address for each
   SCTP association.  Again, because the remote stack may be using ports
   other than the well-known port, each port may be different from each
   stack.  However, because of remapping of ports by NATs, the remote
   ports associated with different remote IP addresses may not be
   identical, even if they are associated with the same stack.

   Because the well-known port might not be used, implementations need
   to allow other port numbers to be specified as a local or remote UDP
   encapsulation port number through APIs.

Patches:

   This patchset is using the udp4/6 tunnel APIs to implement the UDP
   Encapsulation of SCTP with not much change in SCTP protocol stack
   and with all current SCTP features keeped in Linux Kernel.

   1 - 4: Fix some UDP issues that may be triggered by SCTP over UDP.
   5 - 7: Process incoming UDP encapsulated packets and ICMP packets.
   8 -10: Remote encap port's update by sysctl, sockopt and packets.
   11-14: Process outgoing pakects with UDP encapsulated and its GSO.
      15: Enable this feature.

Tests:

  - lksctp-tools/src/func_tests with UDP Encapsulation enabled/disabled:

      Both make v4test and v6test passed.

  - sctp-tests with UDP Encapsulation enabled/disabled:

      repeatability/procdumps/sctpdiag/gsomtuchange/extoverflow/
      sctphashtable passed. Others failed as expected due to those
      "iptables -p sctp" rules.

  - netperf on lo/netns/virtio_net, with gso enabled/disabled and
    with ip_checksum enabled/disabled, with UDP Encapsulation
    enabled/disabled:

      No clear performance dropped.

Xin Long (15):
  udp: check udp sock encap_type in __udp_lib_err
  udp6: move the mss check after udp gso tunnel processing
  udp: do checksum properly in skb_udp_tunnel_segment
  udp: support sctp over udp in skb_udp_tunnel_segment
  sctp: create udp4 sock and add its encap_rcv
  sctp: create udp6 sock and set its encap_rcv
  sctp: add encap_err_lookup for udp encap socks
  sctp: add encap_port for netns sock asoc and transport
  sctp: add SCTP_REMOTE_UDP_ENCAPS_PORT sockopt
  sctp: allow changing transport encap_port by peer packets
  sctp: add udphdr to overhead when udp_port is set
  sctp: call sk_setup_caps in sctp_packet_transmit instead
  sctp: support for sending packet over udp4 sock
  sctp: support for sending packet over udp6 sock
  sctp: enable udp tunneling socks

 include/net/netns/sctp.h     |   8 +++
 include/net/sctp/constants.h |   2 +
 include/net/sctp/sctp.h      |   9 ++-
 include/net/sctp/sm.h        |   1 +
 include/net/sctp/structs.h   |  13 ++--
 include/uapi/linux/sctp.h    |   7 ++
 net/ipv4/udp.c               |   2 +-
 net/ipv4/udp_offload.c       |  16 +++--
 net/ipv6/udp.c               |   2 +-
 net/ipv6/udp_offload.c       | 154 +++++++++++++++++++++----------------------
 net/sctp/associola.c         |   4 ++
 net/sctp/ipv6.c              |  48 ++++++++++----
 net/sctp/output.c            |  22 +++----
 net/sctp/protocol.c          | 145 ++++++++++++++++++++++++++++++++++++----
 net/sctp/sm_make_chunk.c     |   1 +
 net/sctp/sm_statefuns.c      |   2 +
 net/sctp/socket.c            | 111 +++++++++++++++++++++++++++++++
 net/sctp/sysctl.c            |  53 +++++++++++++++
 18 files changed, 471 insertions(+), 129 deletions(-)

-- 
2.1.0


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

* [PATCH net-next 01/15] udp: check udp sock encap_type in __udp_lib_err
  2020-09-29 13:48 [PATCH net-next 00/15] sctp: Implement RFC6951: UDP Encapsulation of SCTP Xin Long
  2020-09-29 13:48 ` Xin Long
@ 2020-09-29 13:48 ` Xin Long
  2020-09-29 13:48   ` Xin Long
  2020-09-29 13:48   ` [PATCH net-next 02/15] udp6: move the mss check after udp gso tunnel processing Xin Long
  2020-09-29 16:39 ` [PATCH net-next 00/15] sctp: Implement RFC6951: UDP Encapsulation of SCTP Michael Tuexen
  2020-10-01 12:41 ` Marcelo Ricardo Leitner
  3 siblings, 2 replies; 82+ messages in thread
From: Xin Long @ 2020-09-29 13:48 UTC (permalink / raw)
  To: network dev, linux-sctp
  Cc: Marcelo Ricardo Leitner, Neil Horman, Michael Tuexen, Tom Herbert, davem

There is a chance that __udp4/6_lib_lookup() returns a udp encap
sock in __udp_lib_err(), like the udp encap listening sock may
use the same port as remote encap port, in which case it should
go to __udp4/6_lib_err_encap() for more validation before
processing the icmp packet.

This patch is to check encap_type in __udp_lib_err() for the
further validation for a encap sock.

Signed-off-by: Xin Long <lucien.xin@gmail.com>
---
 net/ipv4/udp.c | 2 +-
 net/ipv6/udp.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index 09f0a23..ca04a8a 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -702,7 +702,7 @@ int __udp4_lib_err(struct sk_buff *skb, u32 info, struct udp_table *udptable)
 	sk = __udp4_lib_lookup(net, iph->daddr, uh->dest,
 			       iph->saddr, uh->source, skb->dev->ifindex,
 			       inet_sdif(skb), udptable, NULL);
-	if (!sk) {
+	if (!sk || udp_sk(sk)->encap_type) {
 		/* No socket for error: try tunnels before discarding */
 		sk = ERR_PTR(-ENOENT);
 		if (static_branch_unlikely(&udp_encap_needed_key)) {
diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
index 29d9691..cde9b88 100644
--- a/net/ipv6/udp.c
+++ b/net/ipv6/udp.c
@@ -560,7 +560,7 @@ int __udp6_lib_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
 
 	sk = __udp6_lib_lookup(net, daddr, uh->dest, saddr, uh->source,
 			       inet6_iif(skb), inet6_sdif(skb), udptable, NULL);
-	if (!sk) {
+	if (!sk || udp_sk(sk)->encap_type) {
 		/* No socket for error: try tunnels before discarding */
 		sk = ERR_PTR(-ENOENT);
 		if (static_branch_unlikely(&udpv6_encap_needed_key)) {
-- 
2.1.0

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

* [PATCH net-next 01/15] udp: check udp sock encap_type in __udp_lib_err
  2020-09-29 13:48 ` [PATCH net-next 01/15] udp: check udp sock encap_type in __udp_lib_err Xin Long
@ 2020-09-29 13:48   ` Xin Long
  2020-09-29 13:48   ` [PATCH net-next 02/15] udp6: move the mss check after udp gso tunnel processing Xin Long
  1 sibling, 0 replies; 82+ messages in thread
From: Xin Long @ 2020-09-29 13:48 UTC (permalink / raw)
  To: network dev, linux-sctp
  Cc: Marcelo Ricardo Leitner, Neil Horman, Michael Tuexen, Tom Herbert, davem

There is a chance that __udp4/6_lib_lookup() returns a udp encap
sock in __udp_lib_err(), like the udp encap listening sock may
use the same port as remote encap port, in which case it should
go to __udp4/6_lib_err_encap() for more validation before
processing the icmp packet.

This patch is to check encap_type in __udp_lib_err() for the
further validation for a encap sock.

Signed-off-by: Xin Long <lucien.xin@gmail.com>
---
 net/ipv4/udp.c | 2 +-
 net/ipv6/udp.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index 09f0a23..ca04a8a 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -702,7 +702,7 @@ int __udp4_lib_err(struct sk_buff *skb, u32 info, struct udp_table *udptable)
 	sk = __udp4_lib_lookup(net, iph->daddr, uh->dest,
 			       iph->saddr, uh->source, skb->dev->ifindex,
 			       inet_sdif(skb), udptable, NULL);
-	if (!sk) {
+	if (!sk || udp_sk(sk)->encap_type) {
 		/* No socket for error: try tunnels before discarding */
 		sk = ERR_PTR(-ENOENT);
 		if (static_branch_unlikely(&udp_encap_needed_key)) {
diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
index 29d9691..cde9b88 100644
--- a/net/ipv6/udp.c
+++ b/net/ipv6/udp.c
@@ -560,7 +560,7 @@ int __udp6_lib_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
 
 	sk = __udp6_lib_lookup(net, daddr, uh->dest, saddr, uh->source,
 			       inet6_iif(skb), inet6_sdif(skb), udptable, NULL);
-	if (!sk) {
+	if (!sk || udp_sk(sk)->encap_type) {
 		/* No socket for error: try tunnels before discarding */
 		sk = ERR_PTR(-ENOENT);
 		if (static_branch_unlikely(&udpv6_encap_needed_key)) {
-- 
2.1.0


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

* [PATCH net-next 02/15] udp6: move the mss check after udp gso tunnel processing
  2020-09-29 13:48 ` [PATCH net-next 01/15] udp: check udp sock encap_type in __udp_lib_err Xin Long
  2020-09-29 13:48   ` Xin Long
@ 2020-09-29 13:48   ` Xin Long
  2020-09-29 13:48     ` Xin Long
  2020-09-29 13:48     ` [PATCH net-next 03/15] udp: do checksum properly in skb_udp_tunnel_segment Xin Long
  1 sibling, 2 replies; 82+ messages in thread
From: Xin Long @ 2020-09-29 13:48 UTC (permalink / raw)
  To: network dev, linux-sctp
  Cc: Marcelo Ricardo Leitner, Neil Horman, Michael Tuexen, Tom Herbert, davem

For some protocol's gso, like SCTP, it's using GSO_BY_FRAGS for
gso_size. When using UDP to encapsulate its packet, it will
return error in udp6_ufo_fragment() as skb->len < gso_size,
and it will never go to the gso tunnel processing.

So we should move this check after udp gso tunnel processing,
the same as udp4_ufo_fragment() does. While at it, also tidy
the variables up.

Signed-off-by: Xin Long <lucien.xin@gmail.com>
---
 net/ipv6/udp_offload.c | 154 ++++++++++++++++++++++++-------------------------
 1 file changed, 76 insertions(+), 78 deletions(-)

diff --git a/net/ipv6/udp_offload.c b/net/ipv6/udp_offload.c
index 584157a..3c5ec8e 100644
--- a/net/ipv6/udp_offload.c
+++ b/net/ipv6/udp_offload.c
@@ -17,96 +17,94 @@
 static struct sk_buff *udp6_ufo_fragment(struct sk_buff *skb,
 					 netdev_features_t features)
 {
+	u8 nexthdr, frag_hdr_sz = sizeof(struct frag_hdr);
+	unsigned int unfrag_ip6hlen, unfrag_len, mss;
 	struct sk_buff *segs = ERR_PTR(-EINVAL);
-	unsigned int mss;
-	unsigned int unfrag_ip6hlen, unfrag_len;
-	struct frag_hdr *fptr;
+	const struct ipv6hdr *ipv6h;
 	u8 *packet_start, *prevhdr;
-	u8 nexthdr;
-	u8 frag_hdr_sz = sizeof(struct frag_hdr);
+	struct frag_hdr *fptr;
+	int tnl_hlen, err;
+	struct udphdr *uh;
 	__wsum csum;
-	int tnl_hlen;
-	int err;
 
-	mss = skb_shinfo(skb)->gso_size;
-	if (unlikely(skb->len <= mss))
+	if (skb->encapsulation &&
+	    (skb_shinfo(skb)->gso_type &
+	     (SKB_GSO_UDP_TUNNEL | SKB_GSO_UDP_TUNNEL_CSUM))) {
+		segs = skb_udp_tunnel_segment(skb, features, true);
 		goto out;
+	}
 
-	if (skb->encapsulation && skb_shinfo(skb)->gso_type &
-	    (SKB_GSO_UDP_TUNNEL|SKB_GSO_UDP_TUNNEL_CSUM))
-		segs = skb_udp_tunnel_segment(skb, features, true);
-	else {
-		const struct ipv6hdr *ipv6h;
-		struct udphdr *uh;
+	if (!(skb_shinfo(skb)->gso_type & (SKB_GSO_UDP | SKB_GSO_UDP_L4)))
+		goto out;
 
-		if (!(skb_shinfo(skb)->gso_type & (SKB_GSO_UDP | SKB_GSO_UDP_L4)))
-			goto out;
+	if (!pskb_may_pull(skb, sizeof(struct udphdr)))
+		goto out;
 
-		if (!pskb_may_pull(skb, sizeof(struct udphdr)))
-			goto out;
+	if (skb_shinfo(skb)->gso_type & SKB_GSO_UDP_L4)
+		return __udp_gso_segment(skb, features);
 
-		if (skb_shinfo(skb)->gso_type & SKB_GSO_UDP_L4)
-			return __udp_gso_segment(skb, features);
-
-		/* Do software UFO. Complete and fill in the UDP checksum as HW cannot
-		 * do checksum of UDP packets sent as multiple IP fragments.
-		 */
-
-		uh = udp_hdr(skb);
-		ipv6h = ipv6_hdr(skb);
-
-		uh->check = 0;
-		csum = skb_checksum(skb, 0, skb->len, 0);
-		uh->check = udp_v6_check(skb->len, &ipv6h->saddr,
-					  &ipv6h->daddr, csum);
-		if (uh->check = 0)
-			uh->check = CSUM_MANGLED_0;
-
-		skb->ip_summed = CHECKSUM_UNNECESSARY;
-
-		/* If there is no outer header we can fake a checksum offload
-		 * due to the fact that we have already done the checksum in
-		 * software prior to segmenting the frame.
-		 */
-		if (!skb->encap_hdr_csum)
-			features |= NETIF_F_HW_CSUM;
-
-		/* Check if there is enough headroom to insert fragment header. */
-		tnl_hlen = skb_tnl_header_len(skb);
-		if (skb->mac_header < (tnl_hlen + frag_hdr_sz)) {
-			if (gso_pskb_expand_head(skb, tnl_hlen + frag_hdr_sz))
-				goto out;
-		}
+	mss = skb_shinfo(skb)->gso_size;
+	if (unlikely(skb->len <= mss))
+		goto out;
 
-		/* Find the unfragmentable header and shift it left by frag_hdr_sz
-		 * bytes to insert fragment header.
-		 */
-		err = ip6_find_1stfragopt(skb, &prevhdr);
-		if (err < 0)
-			return ERR_PTR(err);
-		unfrag_ip6hlen = err;
-		nexthdr = *prevhdr;
-		*prevhdr = NEXTHDR_FRAGMENT;
-		unfrag_len = (skb_network_header(skb) - skb_mac_header(skb)) +
-			     unfrag_ip6hlen + tnl_hlen;
-		packet_start = (u8 *) skb->head + SKB_GSO_CB(skb)->mac_offset;
-		memmove(packet_start-frag_hdr_sz, packet_start, unfrag_len);
-
-		SKB_GSO_CB(skb)->mac_offset -= frag_hdr_sz;
-		skb->mac_header -= frag_hdr_sz;
-		skb->network_header -= frag_hdr_sz;
-
-		fptr = (struct frag_hdr *)(skb_network_header(skb) + unfrag_ip6hlen);
-		fptr->nexthdr = nexthdr;
-		fptr->reserved = 0;
-		fptr->identification = ipv6_proxy_select_ident(dev_net(skb->dev), skb);
-
-		/* Fragment the skb. ipv6 header and the remaining fields of the
-		 * fragment header are updated in ipv6_gso_segment()
-		 */
-		segs = skb_segment(skb, features);
+	/* Do software UFO. Complete and fill in the UDP checksum as HW cannot
+	 * do checksum of UDP packets sent as multiple IP fragments.
+	 */
+
+	uh = udp_hdr(skb);
+	ipv6h = ipv6_hdr(skb);
+
+	uh->check = 0;
+	csum = skb_checksum(skb, 0, skb->len, 0);
+	uh->check = udp_v6_check(skb->len, &ipv6h->saddr,
+				 &ipv6h->daddr, csum);
+	if (uh->check = 0)
+		uh->check = CSUM_MANGLED_0;
+
+	skb->ip_summed = CHECKSUM_UNNECESSARY;
+
+	/* If there is no outer header we can fake a checksum offload
+	 * due to the fact that we have already done the checksum in
+	 * software prior to segmenting the frame.
+	 */
+	if (!skb->encap_hdr_csum)
+		features |= NETIF_F_HW_CSUM;
+
+	/* Check if there is enough headroom to insert fragment header. */
+	tnl_hlen = skb_tnl_header_len(skb);
+	if (skb->mac_header < (tnl_hlen + frag_hdr_sz)) {
+		if (gso_pskb_expand_head(skb, tnl_hlen + frag_hdr_sz))
+			goto out;
 	}
 
+	/* Find the unfragmentable header and shift it left by frag_hdr_sz
+	 * bytes to insert fragment header.
+	 */
+	err = ip6_find_1stfragopt(skb, &prevhdr);
+	if (err < 0)
+		return ERR_PTR(err);
+	unfrag_ip6hlen = err;
+	nexthdr = *prevhdr;
+	*prevhdr = NEXTHDR_FRAGMENT;
+	unfrag_len = (skb_network_header(skb) - skb_mac_header(skb)) +
+		     unfrag_ip6hlen + tnl_hlen;
+	packet_start = (u8 *)skb->head + SKB_GSO_CB(skb)->mac_offset;
+	memmove(packet_start - frag_hdr_sz, packet_start, unfrag_len);
+
+	SKB_GSO_CB(skb)->mac_offset -= frag_hdr_sz;
+	skb->mac_header -= frag_hdr_sz;
+	skb->network_header -= frag_hdr_sz;
+
+	fptr = (struct frag_hdr *)(skb_network_header(skb) + unfrag_ip6hlen);
+	fptr->nexthdr = nexthdr;
+	fptr->reserved = 0;
+	fptr->identification = ipv6_proxy_select_ident(dev_net(skb->dev), skb);
+
+	/* Fragment the skb. ipv6 header and the remaining fields of the
+	 * fragment header are updated in ipv6_gso_segment()
+	 */
+	segs = skb_segment(skb, features);
+
 out:
 	return segs;
 }
-- 
2.1.0

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

* [PATCH net-next 02/15] udp6: move the mss check after udp gso tunnel processing
  2020-09-29 13:48   ` [PATCH net-next 02/15] udp6: move the mss check after udp gso tunnel processing Xin Long
@ 2020-09-29 13:48     ` Xin Long
  2020-09-29 13:48     ` [PATCH net-next 03/15] udp: do checksum properly in skb_udp_tunnel_segment Xin Long
  1 sibling, 0 replies; 82+ messages in thread
From: Xin Long @ 2020-09-29 13:48 UTC (permalink / raw)
  To: network dev, linux-sctp
  Cc: Marcelo Ricardo Leitner, Neil Horman, Michael Tuexen, Tom Herbert, davem

For some protocol's gso, like SCTP, it's using GSO_BY_FRAGS for
gso_size. When using UDP to encapsulate its packet, it will
return error in udp6_ufo_fragment() as skb->len < gso_size,
and it will never go to the gso tunnel processing.

So we should move this check after udp gso tunnel processing,
the same as udp4_ufo_fragment() does. While at it, also tidy
the variables up.

Signed-off-by: Xin Long <lucien.xin@gmail.com>
---
 net/ipv6/udp_offload.c | 154 ++++++++++++++++++++++++-------------------------
 1 file changed, 76 insertions(+), 78 deletions(-)

diff --git a/net/ipv6/udp_offload.c b/net/ipv6/udp_offload.c
index 584157a..3c5ec8e 100644
--- a/net/ipv6/udp_offload.c
+++ b/net/ipv6/udp_offload.c
@@ -17,96 +17,94 @@
 static struct sk_buff *udp6_ufo_fragment(struct sk_buff *skb,
 					 netdev_features_t features)
 {
+	u8 nexthdr, frag_hdr_sz = sizeof(struct frag_hdr);
+	unsigned int unfrag_ip6hlen, unfrag_len, mss;
 	struct sk_buff *segs = ERR_PTR(-EINVAL);
-	unsigned int mss;
-	unsigned int unfrag_ip6hlen, unfrag_len;
-	struct frag_hdr *fptr;
+	const struct ipv6hdr *ipv6h;
 	u8 *packet_start, *prevhdr;
-	u8 nexthdr;
-	u8 frag_hdr_sz = sizeof(struct frag_hdr);
+	struct frag_hdr *fptr;
+	int tnl_hlen, err;
+	struct udphdr *uh;
 	__wsum csum;
-	int tnl_hlen;
-	int err;
 
-	mss = skb_shinfo(skb)->gso_size;
-	if (unlikely(skb->len <= mss))
+	if (skb->encapsulation &&
+	    (skb_shinfo(skb)->gso_type &
+	     (SKB_GSO_UDP_TUNNEL | SKB_GSO_UDP_TUNNEL_CSUM))) {
+		segs = skb_udp_tunnel_segment(skb, features, true);
 		goto out;
+	}
 
-	if (skb->encapsulation && skb_shinfo(skb)->gso_type &
-	    (SKB_GSO_UDP_TUNNEL|SKB_GSO_UDP_TUNNEL_CSUM))
-		segs = skb_udp_tunnel_segment(skb, features, true);
-	else {
-		const struct ipv6hdr *ipv6h;
-		struct udphdr *uh;
+	if (!(skb_shinfo(skb)->gso_type & (SKB_GSO_UDP | SKB_GSO_UDP_L4)))
+		goto out;
 
-		if (!(skb_shinfo(skb)->gso_type & (SKB_GSO_UDP | SKB_GSO_UDP_L4)))
-			goto out;
+	if (!pskb_may_pull(skb, sizeof(struct udphdr)))
+		goto out;
 
-		if (!pskb_may_pull(skb, sizeof(struct udphdr)))
-			goto out;
+	if (skb_shinfo(skb)->gso_type & SKB_GSO_UDP_L4)
+		return __udp_gso_segment(skb, features);
 
-		if (skb_shinfo(skb)->gso_type & SKB_GSO_UDP_L4)
-			return __udp_gso_segment(skb, features);
-
-		/* Do software UFO. Complete and fill in the UDP checksum as HW cannot
-		 * do checksum of UDP packets sent as multiple IP fragments.
-		 */
-
-		uh = udp_hdr(skb);
-		ipv6h = ipv6_hdr(skb);
-
-		uh->check = 0;
-		csum = skb_checksum(skb, 0, skb->len, 0);
-		uh->check = udp_v6_check(skb->len, &ipv6h->saddr,
-					  &ipv6h->daddr, csum);
-		if (uh->check == 0)
-			uh->check = CSUM_MANGLED_0;
-
-		skb->ip_summed = CHECKSUM_UNNECESSARY;
-
-		/* If there is no outer header we can fake a checksum offload
-		 * due to the fact that we have already done the checksum in
-		 * software prior to segmenting the frame.
-		 */
-		if (!skb->encap_hdr_csum)
-			features |= NETIF_F_HW_CSUM;
-
-		/* Check if there is enough headroom to insert fragment header. */
-		tnl_hlen = skb_tnl_header_len(skb);
-		if (skb->mac_header < (tnl_hlen + frag_hdr_sz)) {
-			if (gso_pskb_expand_head(skb, tnl_hlen + frag_hdr_sz))
-				goto out;
-		}
+	mss = skb_shinfo(skb)->gso_size;
+	if (unlikely(skb->len <= mss))
+		goto out;
 
-		/* Find the unfragmentable header and shift it left by frag_hdr_sz
-		 * bytes to insert fragment header.
-		 */
-		err = ip6_find_1stfragopt(skb, &prevhdr);
-		if (err < 0)
-			return ERR_PTR(err);
-		unfrag_ip6hlen = err;
-		nexthdr = *prevhdr;
-		*prevhdr = NEXTHDR_FRAGMENT;
-		unfrag_len = (skb_network_header(skb) - skb_mac_header(skb)) +
-			     unfrag_ip6hlen + tnl_hlen;
-		packet_start = (u8 *) skb->head + SKB_GSO_CB(skb)->mac_offset;
-		memmove(packet_start-frag_hdr_sz, packet_start, unfrag_len);
-
-		SKB_GSO_CB(skb)->mac_offset -= frag_hdr_sz;
-		skb->mac_header -= frag_hdr_sz;
-		skb->network_header -= frag_hdr_sz;
-
-		fptr = (struct frag_hdr *)(skb_network_header(skb) + unfrag_ip6hlen);
-		fptr->nexthdr = nexthdr;
-		fptr->reserved = 0;
-		fptr->identification = ipv6_proxy_select_ident(dev_net(skb->dev), skb);
-
-		/* Fragment the skb. ipv6 header and the remaining fields of the
-		 * fragment header are updated in ipv6_gso_segment()
-		 */
-		segs = skb_segment(skb, features);
+	/* Do software UFO. Complete and fill in the UDP checksum as HW cannot
+	 * do checksum of UDP packets sent as multiple IP fragments.
+	 */
+
+	uh = udp_hdr(skb);
+	ipv6h = ipv6_hdr(skb);
+
+	uh->check = 0;
+	csum = skb_checksum(skb, 0, skb->len, 0);
+	uh->check = udp_v6_check(skb->len, &ipv6h->saddr,
+				 &ipv6h->daddr, csum);
+	if (uh->check == 0)
+		uh->check = CSUM_MANGLED_0;
+
+	skb->ip_summed = CHECKSUM_UNNECESSARY;
+
+	/* If there is no outer header we can fake a checksum offload
+	 * due to the fact that we have already done the checksum in
+	 * software prior to segmenting the frame.
+	 */
+	if (!skb->encap_hdr_csum)
+		features |= NETIF_F_HW_CSUM;
+
+	/* Check if there is enough headroom to insert fragment header. */
+	tnl_hlen = skb_tnl_header_len(skb);
+	if (skb->mac_header < (tnl_hlen + frag_hdr_sz)) {
+		if (gso_pskb_expand_head(skb, tnl_hlen + frag_hdr_sz))
+			goto out;
 	}
 
+	/* Find the unfragmentable header and shift it left by frag_hdr_sz
+	 * bytes to insert fragment header.
+	 */
+	err = ip6_find_1stfragopt(skb, &prevhdr);
+	if (err < 0)
+		return ERR_PTR(err);
+	unfrag_ip6hlen = err;
+	nexthdr = *prevhdr;
+	*prevhdr = NEXTHDR_FRAGMENT;
+	unfrag_len = (skb_network_header(skb) - skb_mac_header(skb)) +
+		     unfrag_ip6hlen + tnl_hlen;
+	packet_start = (u8 *)skb->head + SKB_GSO_CB(skb)->mac_offset;
+	memmove(packet_start - frag_hdr_sz, packet_start, unfrag_len);
+
+	SKB_GSO_CB(skb)->mac_offset -= frag_hdr_sz;
+	skb->mac_header -= frag_hdr_sz;
+	skb->network_header -= frag_hdr_sz;
+
+	fptr = (struct frag_hdr *)(skb_network_header(skb) + unfrag_ip6hlen);
+	fptr->nexthdr = nexthdr;
+	fptr->reserved = 0;
+	fptr->identification = ipv6_proxy_select_ident(dev_net(skb->dev), skb);
+
+	/* Fragment the skb. ipv6 header and the remaining fields of the
+	 * fragment header are updated in ipv6_gso_segment()
+	 */
+	segs = skb_segment(skb, features);
+
 out:
 	return segs;
 }
-- 
2.1.0


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

* [PATCH net-next 03/15] udp: do checksum properly in skb_udp_tunnel_segment
  2020-09-29 13:48   ` [PATCH net-next 02/15] udp6: move the mss check after udp gso tunnel processing Xin Long
  2020-09-29 13:48     ` Xin Long
@ 2020-09-29 13:48     ` Xin Long
  2020-09-29 13:48       ` Xin Long
                         ` (2 more replies)
  1 sibling, 3 replies; 82+ messages in thread
From: Xin Long @ 2020-09-29 13:48 UTC (permalink / raw)
  To: network dev, linux-sctp
  Cc: Marcelo Ricardo Leitner, Neil Horman, Michael Tuexen, Tom Herbert, davem

This patch fixes two things:

  When skb->ip_summed = CHECKSUM_PARTIAL, skb_checksum_help() should be
  called do the checksum, instead of gso_make_checksum(), which is used
  to do the checksum for current proto after calling skb_segment(), not
  after the inner proto's gso_segment().

  When offload_csum is disabled, the hardware will not do the checksum
  for the current proto, udp. So instead of calling gso_make_checksum(),
  it should calculate checksum for udp itself.

Signed-off-by: Xin Long <lucien.xin@gmail.com>
---
 net/ipv4/udp_offload.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/net/ipv4/udp_offload.c b/net/ipv4/udp_offload.c
index e67a66f..c0b010b 100644
--- a/net/ipv4/udp_offload.c
+++ b/net/ipv4/udp_offload.c
@@ -131,14 +131,15 @@ static struct sk_buff *__skb_udp_tunnel_segment(struct sk_buff *skb,
 		uh->check = ~csum_fold(csum_add(partial,
 				       (__force __wsum)htonl(len)));
 
-		if (skb->encapsulation || !offload_csum) {
-			uh->check = gso_make_checksum(skb, ~uh->check);
-			if (uh->check = 0)
-				uh->check = CSUM_MANGLED_0;
-		} else {
+		if (skb->encapsulation)
+			skb_checksum_help(skb);
+
+		if (offload_csum) {
 			skb->ip_summed = CHECKSUM_PARTIAL;
 			skb->csum_start = skb_transport_header(skb) - skb->head;
 			skb->csum_offset = offsetof(struct udphdr, check);
+		} else {
+			uh->check = csum_fold(skb_checksum(skb, udp_offset, len, 0));
 		}
 	} while ((skb = skb->next));
 out:
-- 
2.1.0

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

* [PATCH net-next 03/15] udp: do checksum properly in skb_udp_tunnel_segment
  2020-09-29 13:48     ` [PATCH net-next 03/15] udp: do checksum properly in skb_udp_tunnel_segment Xin Long
@ 2020-09-29 13:48       ` Xin Long
  2020-09-29 13:48       ` [PATCH net-next 04/15] udp: support sctp over udp " Xin Long
  2020-10-03  4:04       ` [PATCH net-next 03/15] udp: do checksum properly in skb_udp_tunnel_segment Marcelo Ricardo Leitner
  2 siblings, 0 replies; 82+ messages in thread
From: Xin Long @ 2020-09-29 13:48 UTC (permalink / raw)
  To: network dev, linux-sctp
  Cc: Marcelo Ricardo Leitner, Neil Horman, Michael Tuexen, Tom Herbert, davem

This patch fixes two things:

  When skb->ip_summed == CHECKSUM_PARTIAL, skb_checksum_help() should be
  called do the checksum, instead of gso_make_checksum(), which is used
  to do the checksum for current proto after calling skb_segment(), not
  after the inner proto's gso_segment().

  When offload_csum is disabled, the hardware will not do the checksum
  for the current proto, udp. So instead of calling gso_make_checksum(),
  it should calculate checksum for udp itself.

Signed-off-by: Xin Long <lucien.xin@gmail.com>
---
 net/ipv4/udp_offload.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/net/ipv4/udp_offload.c b/net/ipv4/udp_offload.c
index e67a66f..c0b010b 100644
--- a/net/ipv4/udp_offload.c
+++ b/net/ipv4/udp_offload.c
@@ -131,14 +131,15 @@ static struct sk_buff *__skb_udp_tunnel_segment(struct sk_buff *skb,
 		uh->check = ~csum_fold(csum_add(partial,
 				       (__force __wsum)htonl(len)));
 
-		if (skb->encapsulation || !offload_csum) {
-			uh->check = gso_make_checksum(skb, ~uh->check);
-			if (uh->check == 0)
-				uh->check = CSUM_MANGLED_0;
-		} else {
+		if (skb->encapsulation)
+			skb_checksum_help(skb);
+
+		if (offload_csum) {
 			skb->ip_summed = CHECKSUM_PARTIAL;
 			skb->csum_start = skb_transport_header(skb) - skb->head;
 			skb->csum_offset = offsetof(struct udphdr, check);
+		} else {
+			uh->check = csum_fold(skb_checksum(skb, udp_offset, len, 0));
 		}
 	} while ((skb = skb->next));
 out:
-- 
2.1.0


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

* [PATCH net-next 04/15] udp: support sctp over udp in skb_udp_tunnel_segment
  2020-09-29 13:48     ` [PATCH net-next 03/15] udp: do checksum properly in skb_udp_tunnel_segment Xin Long
  2020-09-29 13:48       ` Xin Long
@ 2020-09-29 13:48       ` Xin Long
  2020-09-29 13:48         ` Xin Long
  2020-09-29 13:48         ` [PATCH net-next 05/15] sctp: create udp4 sock and add its encap_rcv Xin Long
  2020-10-03  4:04       ` [PATCH net-next 03/15] udp: do checksum properly in skb_udp_tunnel_segment Marcelo Ricardo Leitner
  2 siblings, 2 replies; 82+ messages in thread
From: Xin Long @ 2020-09-29 13:48 UTC (permalink / raw)
  To: network dev, linux-sctp
  Cc: Marcelo Ricardo Leitner, Neil Horman, Michael Tuexen, Tom Herbert, davem

To call sctp_gso_segment() properly in skb_udp_tunnel_segment() for sctp
over udp packets, we need to set transport_header to sctp header. When
skb->ip_summed = CHECKSUM_PARTIAL, skb_crc32c_csum_help() should be
called for the inner sctp packet.

Signed-off-by: Xin Long <lucien.xin@gmail.com>
---
 net/ipv4/udp_offload.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/net/ipv4/udp_offload.c b/net/ipv4/udp_offload.c
index c0b010b..a484405 100644
--- a/net/ipv4/udp_offload.c
+++ b/net/ipv4/udp_offload.c
@@ -49,6 +49,7 @@ static struct sk_buff *__skb_udp_tunnel_segment(struct sk_buff *skb,
 	__skb_pull(skb, tnl_hlen);
 	skb_reset_mac_header(skb);
 	skb_set_network_header(skb, skb_inner_network_offset(skb));
+	skb_set_transport_header(skb, skb_inner_transport_offset(skb));
 	skb->mac_len = skb_inner_network_offset(skb);
 	skb->protocol = new_protocol;
 
@@ -131,8 +132,12 @@ static struct sk_buff *__skb_udp_tunnel_segment(struct sk_buff *skb,
 		uh->check = ~csum_fold(csum_add(partial,
 				       (__force __wsum)htonl(len)));
 
-		if (skb->encapsulation)
-			skb_checksum_help(skb);
+		if (skb->encapsulation) {
+			if (skb->csum_not_inet)
+				skb_crc32c_csum_help(skb);
+			else
+				skb_checksum_help(skb);
+		}
 
 		if (offload_csum) {
 			skb->ip_summed = CHECKSUM_PARTIAL;
-- 
2.1.0

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

* [PATCH net-next 04/15] udp: support sctp over udp in skb_udp_tunnel_segment
  2020-09-29 13:48       ` [PATCH net-next 04/15] udp: support sctp over udp " Xin Long
@ 2020-09-29 13:48         ` Xin Long
  2020-09-29 13:48         ` [PATCH net-next 05/15] sctp: create udp4 sock and add its encap_rcv Xin Long
  1 sibling, 0 replies; 82+ messages in thread
From: Xin Long @ 2020-09-29 13:48 UTC (permalink / raw)
  To: network dev, linux-sctp
  Cc: Marcelo Ricardo Leitner, Neil Horman, Michael Tuexen, Tom Herbert, davem

To call sctp_gso_segment() properly in skb_udp_tunnel_segment() for sctp
over udp packets, we need to set transport_header to sctp header. When
skb->ip_summed == CHECKSUM_PARTIAL, skb_crc32c_csum_help() should be
called for the inner sctp packet.

Signed-off-by: Xin Long <lucien.xin@gmail.com>
---
 net/ipv4/udp_offload.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/net/ipv4/udp_offload.c b/net/ipv4/udp_offload.c
index c0b010b..a484405 100644
--- a/net/ipv4/udp_offload.c
+++ b/net/ipv4/udp_offload.c
@@ -49,6 +49,7 @@ static struct sk_buff *__skb_udp_tunnel_segment(struct sk_buff *skb,
 	__skb_pull(skb, tnl_hlen);
 	skb_reset_mac_header(skb);
 	skb_set_network_header(skb, skb_inner_network_offset(skb));
+	skb_set_transport_header(skb, skb_inner_transport_offset(skb));
 	skb->mac_len = skb_inner_network_offset(skb);
 	skb->protocol = new_protocol;
 
@@ -131,8 +132,12 @@ static struct sk_buff *__skb_udp_tunnel_segment(struct sk_buff *skb,
 		uh->check = ~csum_fold(csum_add(partial,
 				       (__force __wsum)htonl(len)));
 
-		if (skb->encapsulation)
-			skb_checksum_help(skb);
+		if (skb->encapsulation) {
+			if (skb->csum_not_inet)
+				skb_crc32c_csum_help(skb);
+			else
+				skb_checksum_help(skb);
+		}
 
 		if (offload_csum) {
 			skb->ip_summed = CHECKSUM_PARTIAL;
-- 
2.1.0


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

* [PATCH net-next 05/15] sctp: create udp4 sock and add its encap_rcv
  2020-09-29 13:48       ` [PATCH net-next 04/15] udp: support sctp over udp " Xin Long
  2020-09-29 13:48         ` Xin Long
@ 2020-09-29 13:48         ` Xin Long
  2020-09-29 13:48           ` Xin Long
  2020-09-29 13:48           ` [PATCH net-next 06/15] sctp: create udp6 sock and set " Xin Long
  1 sibling, 2 replies; 82+ messages in thread
From: Xin Long @ 2020-09-29 13:48 UTC (permalink / raw)
  To: network dev, linux-sctp
  Cc: Marcelo Ricardo Leitner, Neil Horman, Michael Tuexen, Tom Herbert, davem

This patch is to add the functions to create/release udp4 sock,
and set the sock's encap_rcv to process the incoming udp encap
sctp packets. In sctp_udp_rcv(), as we can see, all we need to
do is fix the transport header for sctp_rcv(), then it would
implement the part of rfc6951#section-5.4:

  "When an encapsulated packet is received, the UDP header is removed.
   Then, the generic lookup is performed, as done by an SCTP stack
   whenever a packet is received, to find the association for the
   received SCTP packet"

Note that these functions will be called in the last patch of
this patchset when enabling this feature.

Signed-off-by: Xin Long <lucien.xin@gmail.com>
---
 include/net/netns/sctp.h     |  5 +++++
 include/net/sctp/constants.h |  2 ++
 include/net/sctp/sctp.h      |  2 ++
 net/sctp/protocol.c          | 40 ++++++++++++++++++++++++++++++++++++++++
 4 files changed, 49 insertions(+)

diff --git a/include/net/netns/sctp.h b/include/net/netns/sctp.h
index d8d02e4..3d10bef 100644
--- a/include/net/netns/sctp.h
+++ b/include/net/netns/sctp.h
@@ -22,6 +22,11 @@ struct netns_sctp {
 	 */
 	struct sock *ctl_sock;
 
+	/* udp tunneling listening sock. */
+	struct sock *udp4_sock;
+	/* udp tunneling listening port. */
+	int udp_port;
+
 	/* This is the global local address list.
 	 * We actively maintain this complete list of addresses on
 	 * the system by catching address add/delete events.
diff --git a/include/net/sctp/constants.h b/include/net/sctp/constants.h
index 122d9e2..b583166 100644
--- a/include/net/sctp/constants.h
+++ b/include/net/sctp/constants.h
@@ -286,6 +286,8 @@ enum { SCTP_MAX_GABS = 16 };
 				 * functions simpler to write.
 				 */
 
+#define SCTP_DEFAULT_UDP_PORT 9899	/* default udp tunneling port */
+
 /* These are the values for pf exposure, UNUSED is to keep compatible with old
  * applications by default.
  */
diff --git a/include/net/sctp/sctp.h b/include/net/sctp/sctp.h
index 4fc747b..bfd87a0 100644
--- a/include/net/sctp/sctp.h
+++ b/include/net/sctp/sctp.h
@@ -84,6 +84,8 @@ int sctp_copy_local_addr_list(struct net *net, struct sctp_bind_addr *addr,
 struct sctp_pf *sctp_get_pf_specific(sa_family_t family);
 int sctp_register_pf(struct sctp_pf *, sa_family_t);
 void sctp_addr_wq_mgmt(struct net *, struct sctp_sockaddr_entry *, int);
+int sctp_udp_sock_start(struct net *net);
+void sctp_udp_sock_stop(struct net *net);
 
 /*
  * sctp/socket.c
diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
index 2583323..f194b60 100644
--- a/net/sctp/protocol.c
+++ b/net/sctp/protocol.c
@@ -840,6 +840,43 @@ static int sctp_ctl_sock_init(struct net *net)
 	return 0;
 }
 
+static int sctp_udp_rcv(struct sock *sk, struct sk_buff *skb)
+{
+	skb_set_transport_header(skb, sizeof(struct udphdr));
+	sctp_rcv(skb);
+	return 0;
+}
+
+int sctp_udp_sock_start(struct net *net)
+{
+	struct udp_tunnel_sock_cfg tuncfg = {NULL};
+	struct udp_port_cfg udp_conf = {0};
+	struct socket *sock;
+	int err;
+
+	udp_conf.family = AF_INET;
+	udp_conf.local_ip.s_addr = htonl(INADDR_ANY);
+	udp_conf.local_udp_port = htons(net->sctp.udp_port);
+	err = udp_sock_create(net, &udp_conf, &sock);
+	if (err)
+		return err;
+
+	tuncfg.encap_type = 1;
+	tuncfg.encap_rcv = sctp_udp_rcv;
+	setup_udp_tunnel_sock(net, sock, &tuncfg);
+	net->sctp.udp4_sock = sock->sk;
+
+	return 0;
+}
+
+void sctp_udp_sock_stop(struct net *net)
+{
+	if (net->sctp.udp4_sock) {
+		udp_tunnel_sock_release(net->sctp.udp4_sock->sk_socket);
+		net->sctp.udp4_sock = NULL;
+	}
+}
+
 /* Register address family specific functions. */
 int sctp_register_af(struct sctp_af *af)
 {
@@ -1271,6 +1308,9 @@ static int __net_init sctp_defaults_init(struct net *net)
 	/* Enable ECN by default. */
 	net->sctp.ecn_enable = 1;
 
+	/* Set udp tunneling listening port to default value */
+	net->sctp.udp_port = SCTP_DEFAULT_UDP_PORT;
+
 	/* Set SCOPE policy to enabled */
 	net->sctp.scope_policy = SCTP_SCOPE_POLICY_ENABLE;
 
-- 
2.1.0

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

* [PATCH net-next 05/15] sctp: create udp4 sock and add its encap_rcv
  2020-09-29 13:48         ` [PATCH net-next 05/15] sctp: create udp4 sock and add its encap_rcv Xin Long
@ 2020-09-29 13:48           ` Xin Long
  2020-09-29 13:48           ` [PATCH net-next 06/15] sctp: create udp6 sock and set " Xin Long
  1 sibling, 0 replies; 82+ messages in thread
From: Xin Long @ 2020-09-29 13:48 UTC (permalink / raw)
  To: network dev, linux-sctp
  Cc: Marcelo Ricardo Leitner, Neil Horman, Michael Tuexen, Tom Herbert, davem

This patch is to add the functions to create/release udp4 sock,
and set the sock's encap_rcv to process the incoming udp encap
sctp packets. In sctp_udp_rcv(), as we can see, all we need to
do is fix the transport header for sctp_rcv(), then it would
implement the part of rfc6951#section-5.4:

  "When an encapsulated packet is received, the UDP header is removed.
   Then, the generic lookup is performed, as done by an SCTP stack
   whenever a packet is received, to find the association for the
   received SCTP packet"

Note that these functions will be called in the last patch of
this patchset when enabling this feature.

Signed-off-by: Xin Long <lucien.xin@gmail.com>
---
 include/net/netns/sctp.h     |  5 +++++
 include/net/sctp/constants.h |  2 ++
 include/net/sctp/sctp.h      |  2 ++
 net/sctp/protocol.c          | 40 ++++++++++++++++++++++++++++++++++++++++
 4 files changed, 49 insertions(+)

diff --git a/include/net/netns/sctp.h b/include/net/netns/sctp.h
index d8d02e4..3d10bef 100644
--- a/include/net/netns/sctp.h
+++ b/include/net/netns/sctp.h
@@ -22,6 +22,11 @@ struct netns_sctp {
 	 */
 	struct sock *ctl_sock;
 
+	/* udp tunneling listening sock. */
+	struct sock *udp4_sock;
+	/* udp tunneling listening port. */
+	int udp_port;
+
 	/* This is the global local address list.
 	 * We actively maintain this complete list of addresses on
 	 * the system by catching address add/delete events.
diff --git a/include/net/sctp/constants.h b/include/net/sctp/constants.h
index 122d9e2..b583166 100644
--- a/include/net/sctp/constants.h
+++ b/include/net/sctp/constants.h
@@ -286,6 +286,8 @@ enum { SCTP_MAX_GABS = 16 };
 				 * functions simpler to write.
 				 */
 
+#define SCTP_DEFAULT_UDP_PORT 9899	/* default udp tunneling port */
+
 /* These are the values for pf exposure, UNUSED is to keep compatible with old
  * applications by default.
  */
diff --git a/include/net/sctp/sctp.h b/include/net/sctp/sctp.h
index 4fc747b..bfd87a0 100644
--- a/include/net/sctp/sctp.h
+++ b/include/net/sctp/sctp.h
@@ -84,6 +84,8 @@ int sctp_copy_local_addr_list(struct net *net, struct sctp_bind_addr *addr,
 struct sctp_pf *sctp_get_pf_specific(sa_family_t family);
 int sctp_register_pf(struct sctp_pf *, sa_family_t);
 void sctp_addr_wq_mgmt(struct net *, struct sctp_sockaddr_entry *, int);
+int sctp_udp_sock_start(struct net *net);
+void sctp_udp_sock_stop(struct net *net);
 
 /*
  * sctp/socket.c
diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
index 2583323..f194b60 100644
--- a/net/sctp/protocol.c
+++ b/net/sctp/protocol.c
@@ -840,6 +840,43 @@ static int sctp_ctl_sock_init(struct net *net)
 	return 0;
 }
 
+static int sctp_udp_rcv(struct sock *sk, struct sk_buff *skb)
+{
+	skb_set_transport_header(skb, sizeof(struct udphdr));
+	sctp_rcv(skb);
+	return 0;
+}
+
+int sctp_udp_sock_start(struct net *net)
+{
+	struct udp_tunnel_sock_cfg tuncfg = {NULL};
+	struct udp_port_cfg udp_conf = {0};
+	struct socket *sock;
+	int err;
+
+	udp_conf.family = AF_INET;
+	udp_conf.local_ip.s_addr = htonl(INADDR_ANY);
+	udp_conf.local_udp_port = htons(net->sctp.udp_port);
+	err = udp_sock_create(net, &udp_conf, &sock);
+	if (err)
+		return err;
+
+	tuncfg.encap_type = 1;
+	tuncfg.encap_rcv = sctp_udp_rcv;
+	setup_udp_tunnel_sock(net, sock, &tuncfg);
+	net->sctp.udp4_sock = sock->sk;
+
+	return 0;
+}
+
+void sctp_udp_sock_stop(struct net *net)
+{
+	if (net->sctp.udp4_sock) {
+		udp_tunnel_sock_release(net->sctp.udp4_sock->sk_socket);
+		net->sctp.udp4_sock = NULL;
+	}
+}
+
 /* Register address family specific functions. */
 int sctp_register_af(struct sctp_af *af)
 {
@@ -1271,6 +1308,9 @@ static int __net_init sctp_defaults_init(struct net *net)
 	/* Enable ECN by default. */
 	net->sctp.ecn_enable = 1;
 
+	/* Set udp tunneling listening port to default value */
+	net->sctp.udp_port = SCTP_DEFAULT_UDP_PORT;
+
 	/* Set SCOPE policy to enabled */
 	net->sctp.scope_policy = SCTP_SCOPE_POLICY_ENABLE;
 
-- 
2.1.0


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

* [PATCH net-next 06/15] sctp: create udp6 sock and set its encap_rcv
  2020-09-29 13:48         ` [PATCH net-next 05/15] sctp: create udp4 sock and add its encap_rcv Xin Long
  2020-09-29 13:48           ` Xin Long
@ 2020-09-29 13:48           ` Xin Long
  2020-09-29 13:48             ` Xin Long
  2020-09-29 13:48             ` [PATCH net-next 07/15] sctp: add encap_err_lookup for udp encap socks Xin Long
  1 sibling, 2 replies; 82+ messages in thread
From: Xin Long @ 2020-09-29 13:48 UTC (permalink / raw)
  To: network dev, linux-sctp
  Cc: Marcelo Ricardo Leitner, Neil Horman, Michael Tuexen, Tom Herbert, davem

This patch is to add the udp6 sock part in sctp_udp_sock_start/stop().
udp_conf.use_udp6_rx_checksums is set to true, as:

   "The SCTP checksum MUST be computed for IPv4 and IPv6, and the UDP
    checksum SHOULD be computed for IPv4 and IPv6"

says in rfc6951#section-5.3.

Signed-off-by: Xin Long <lucien.xin@gmail.com>
---
 include/net/netns/sctp.h |  1 +
 net/sctp/protocol.c      | 23 +++++++++++++++++++++++
 2 files changed, 24 insertions(+)

diff --git a/include/net/netns/sctp.h b/include/net/netns/sctp.h
index 3d10bef..f622945 100644
--- a/include/net/netns/sctp.h
+++ b/include/net/netns/sctp.h
@@ -24,6 +24,7 @@ struct netns_sctp {
 
 	/* udp tunneling listening sock. */
 	struct sock *udp4_sock;
+	struct sock *udp6_sock;
 	/* udp tunneling listening port. */
 	int udp_port;
 
diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
index f194b60..0aaa24d 100644
--- a/net/sctp/protocol.c
+++ b/net/sctp/protocol.c
@@ -866,6 +866,25 @@ int sctp_udp_sock_start(struct net *net)
 	setup_udp_tunnel_sock(net, sock, &tuncfg);
 	net->sctp.udp4_sock = sock->sk;
 
+	memset(&udp_conf, 0, sizeof(udp_conf));
+
+	udp_conf.family = AF_INET6;
+	udp_conf.local_ip6 = in6addr_any;
+	udp_conf.local_udp_port = htons(net->sctp.udp_port);
+	udp_conf.use_udp6_rx_checksums = true;
+	udp_conf.ipv6_v6only = true;
+	err = udp_sock_create(net, &udp_conf, &sock);
+	if (err) {
+		udp_tunnel_sock_release(net->sctp.udp4_sock->sk_socket);
+		net->sctp.udp4_sock = NULL;
+		return err;
+	}
+
+	tuncfg.encap_type = 1;
+	tuncfg.encap_rcv = sctp_udp_rcv;
+	setup_udp_tunnel_sock(net, sock, &tuncfg);
+	net->sctp.udp6_sock = sock->sk;
+
 	return 0;
 }
 
@@ -875,6 +894,10 @@ void sctp_udp_sock_stop(struct net *net)
 		udp_tunnel_sock_release(net->sctp.udp4_sock->sk_socket);
 		net->sctp.udp4_sock = NULL;
 	}
+	if (net->sctp.udp6_sock) {
+		udp_tunnel_sock_release(net->sctp.udp6_sock->sk_socket);
+		net->sctp.udp6_sock = NULL;
+	}
 }
 
 /* Register address family specific functions. */
-- 
2.1.0

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

* [PATCH net-next 06/15] sctp: create udp6 sock and set its encap_rcv
  2020-09-29 13:48           ` [PATCH net-next 06/15] sctp: create udp6 sock and set " Xin Long
@ 2020-09-29 13:48             ` Xin Long
  2020-09-29 13:48             ` [PATCH net-next 07/15] sctp: add encap_err_lookup for udp encap socks Xin Long
  1 sibling, 0 replies; 82+ messages in thread
From: Xin Long @ 2020-09-29 13:48 UTC (permalink / raw)
  To: network dev, linux-sctp
  Cc: Marcelo Ricardo Leitner, Neil Horman, Michael Tuexen, Tom Herbert, davem

This patch is to add the udp6 sock part in sctp_udp_sock_start/stop().
udp_conf.use_udp6_rx_checksums is set to true, as:

   "The SCTP checksum MUST be computed for IPv4 and IPv6, and the UDP
    checksum SHOULD be computed for IPv4 and IPv6"

says in rfc6951#section-5.3.

Signed-off-by: Xin Long <lucien.xin@gmail.com>
---
 include/net/netns/sctp.h |  1 +
 net/sctp/protocol.c      | 23 +++++++++++++++++++++++
 2 files changed, 24 insertions(+)

diff --git a/include/net/netns/sctp.h b/include/net/netns/sctp.h
index 3d10bef..f622945 100644
--- a/include/net/netns/sctp.h
+++ b/include/net/netns/sctp.h
@@ -24,6 +24,7 @@ struct netns_sctp {
 
 	/* udp tunneling listening sock. */
 	struct sock *udp4_sock;
+	struct sock *udp6_sock;
 	/* udp tunneling listening port. */
 	int udp_port;
 
diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
index f194b60..0aaa24d 100644
--- a/net/sctp/protocol.c
+++ b/net/sctp/protocol.c
@@ -866,6 +866,25 @@ int sctp_udp_sock_start(struct net *net)
 	setup_udp_tunnel_sock(net, sock, &tuncfg);
 	net->sctp.udp4_sock = sock->sk;
 
+	memset(&udp_conf, 0, sizeof(udp_conf));
+
+	udp_conf.family = AF_INET6;
+	udp_conf.local_ip6 = in6addr_any;
+	udp_conf.local_udp_port = htons(net->sctp.udp_port);
+	udp_conf.use_udp6_rx_checksums = true;
+	udp_conf.ipv6_v6only = true;
+	err = udp_sock_create(net, &udp_conf, &sock);
+	if (err) {
+		udp_tunnel_sock_release(net->sctp.udp4_sock->sk_socket);
+		net->sctp.udp4_sock = NULL;
+		return err;
+	}
+
+	tuncfg.encap_type = 1;
+	tuncfg.encap_rcv = sctp_udp_rcv;
+	setup_udp_tunnel_sock(net, sock, &tuncfg);
+	net->sctp.udp6_sock = sock->sk;
+
 	return 0;
 }
 
@@ -875,6 +894,10 @@ void sctp_udp_sock_stop(struct net *net)
 		udp_tunnel_sock_release(net->sctp.udp4_sock->sk_socket);
 		net->sctp.udp4_sock = NULL;
 	}
+	if (net->sctp.udp6_sock) {
+		udp_tunnel_sock_release(net->sctp.udp6_sock->sk_socket);
+		net->sctp.udp6_sock = NULL;
+	}
 }
 
 /* Register address family specific functions. */
-- 
2.1.0


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

* [PATCH net-next 07/15] sctp: add encap_err_lookup for udp encap socks
  2020-09-29 13:48           ` [PATCH net-next 06/15] sctp: create udp6 sock and set " Xin Long
  2020-09-29 13:48             ` Xin Long
@ 2020-09-29 13:48             ` Xin Long
  2020-09-29 13:48               ` Xin Long
  2020-09-29 13:49               ` [PATCH net-next 08/15] sctp: add encap_port for netns sock asoc and transport Xin Long
  1 sibling, 2 replies; 82+ messages in thread
From: Xin Long @ 2020-09-29 13:48 UTC (permalink / raw)
  To: network dev, linux-sctp
  Cc: Marcelo Ricardo Leitner, Neil Horman, Michael Tuexen, Tom Herbert, davem

As says in rfc6951#section-5.5:

  "When receiving ICMP or ICMPv6 response packets, there might not be
   enough bytes in the payload to identify the SCTP association that the
   SCTP packet triggering the ICMP or ICMPv6 packet belongs to.  If a
   received ICMP or ICMPv6 packet cannot be related to a specific SCTP
   association or the verification tag cannot be verified, it MUST be
   discarded silently.  In particular, this means that the SCTP stack
   MUST NOT rely on receiving ICMP or ICMPv6 messages.  Implementation
   constraints could prevent processing received ICMP or ICMPv6
   messages."

ICMP or ICMPv6 packets need to be handled, and this is implemented by
udp encap sock .encap_err_lookup function.

The .encap_err_lookup function is called in __udp(6)_lib_err_encap()
to confirm this path does need to be updated. For sctp, what we can
do here is check if the corresponding asoc and transport exists.

Note that icmp packet process for sctp over udp is done by udp sock
.encap_err_lookup(), and it means for now we can't do as much as
sctp_v4/6_err() does. Also we can't do the two mappings mentioned
in rfc6951#section-5.5.

Signed-off-by: Xin Long <lucien.xin@gmail.com>
---
 net/sctp/protocol.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
index 0aaa24d..953891b 100644
--- a/net/sctp/protocol.c
+++ b/net/sctp/protocol.c
@@ -847,6 +847,23 @@ static int sctp_udp_rcv(struct sock *sk, struct sk_buff *skb)
 	return 0;
 }
 
+static int sctp_udp_err_lookup(struct sock *sk, struct sk_buff *skb)
+{
+	struct sctp_association *asoc;
+	struct sctp_transport *t;
+	int family;
+
+	skb->transport_header += sizeof(struct udphdr);
+	family = (ip_hdr(skb)->version = 4) ? AF_INET : AF_INET6;
+	sk = sctp_err_lookup(dev_net(skb->dev), family, skb, sctp_hdr(skb),
+			     &asoc, &t);
+	if (!sk)
+		return -ENOENT;
+
+	sctp_err_finish(sk, t);
+	return 0;
+}
+
 int sctp_udp_sock_start(struct net *net)
 {
 	struct udp_tunnel_sock_cfg tuncfg = {NULL};
@@ -863,6 +880,7 @@ int sctp_udp_sock_start(struct net *net)
 
 	tuncfg.encap_type = 1;
 	tuncfg.encap_rcv = sctp_udp_rcv;
+	tuncfg.encap_err_lookup = sctp_udp_err_lookup;
 	setup_udp_tunnel_sock(net, sock, &tuncfg);
 	net->sctp.udp4_sock = sock->sk;
 
@@ -882,6 +900,7 @@ int sctp_udp_sock_start(struct net *net)
 
 	tuncfg.encap_type = 1;
 	tuncfg.encap_rcv = sctp_udp_rcv;
+	tuncfg.encap_err_lookup = sctp_udp_err_lookup;
 	setup_udp_tunnel_sock(net, sock, &tuncfg);
 	net->sctp.udp6_sock = sock->sk;
 
-- 
2.1.0

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

* [PATCH net-next 07/15] sctp: add encap_err_lookup for udp encap socks
  2020-09-29 13:48             ` [PATCH net-next 07/15] sctp: add encap_err_lookup for udp encap socks Xin Long
@ 2020-09-29 13:48               ` Xin Long
  2020-09-29 13:49               ` [PATCH net-next 08/15] sctp: add encap_port for netns sock asoc and transport Xin Long
  1 sibling, 0 replies; 82+ messages in thread
From: Xin Long @ 2020-09-29 13:48 UTC (permalink / raw)
  To: network dev, linux-sctp
  Cc: Marcelo Ricardo Leitner, Neil Horman, Michael Tuexen, Tom Herbert, davem

As says in rfc6951#section-5.5:

  "When receiving ICMP or ICMPv6 response packets, there might not be
   enough bytes in the payload to identify the SCTP association that the
   SCTP packet triggering the ICMP or ICMPv6 packet belongs to.  If a
   received ICMP or ICMPv6 packet cannot be related to a specific SCTP
   association or the verification tag cannot be verified, it MUST be
   discarded silently.  In particular, this means that the SCTP stack
   MUST NOT rely on receiving ICMP or ICMPv6 messages.  Implementation
   constraints could prevent processing received ICMP or ICMPv6
   messages."

ICMP or ICMPv6 packets need to be handled, and this is implemented by
udp encap sock .encap_err_lookup function.

The .encap_err_lookup function is called in __udp(6)_lib_err_encap()
to confirm this path does need to be updated. For sctp, what we can
do here is check if the corresponding asoc and transport exists.

Note that icmp packet process for sctp over udp is done by udp sock
.encap_err_lookup(), and it means for now we can't do as much as
sctp_v4/6_err() does. Also we can't do the two mappings mentioned
in rfc6951#section-5.5.

Signed-off-by: Xin Long <lucien.xin@gmail.com>
---
 net/sctp/protocol.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
index 0aaa24d..953891b 100644
--- a/net/sctp/protocol.c
+++ b/net/sctp/protocol.c
@@ -847,6 +847,23 @@ static int sctp_udp_rcv(struct sock *sk, struct sk_buff *skb)
 	return 0;
 }
 
+static int sctp_udp_err_lookup(struct sock *sk, struct sk_buff *skb)
+{
+	struct sctp_association *asoc;
+	struct sctp_transport *t;
+	int family;
+
+	skb->transport_header += sizeof(struct udphdr);
+	family = (ip_hdr(skb)->version == 4) ? AF_INET : AF_INET6;
+	sk = sctp_err_lookup(dev_net(skb->dev), family, skb, sctp_hdr(skb),
+			     &asoc, &t);
+	if (!sk)
+		return -ENOENT;
+
+	sctp_err_finish(sk, t);
+	return 0;
+}
+
 int sctp_udp_sock_start(struct net *net)
 {
 	struct udp_tunnel_sock_cfg tuncfg = {NULL};
@@ -863,6 +880,7 @@ int sctp_udp_sock_start(struct net *net)
 
 	tuncfg.encap_type = 1;
 	tuncfg.encap_rcv = sctp_udp_rcv;
+	tuncfg.encap_err_lookup = sctp_udp_err_lookup;
 	setup_udp_tunnel_sock(net, sock, &tuncfg);
 	net->sctp.udp4_sock = sock->sk;
 
@@ -882,6 +900,7 @@ int sctp_udp_sock_start(struct net *net)
 
 	tuncfg.encap_type = 1;
 	tuncfg.encap_rcv = sctp_udp_rcv;
+	tuncfg.encap_err_lookup = sctp_udp_err_lookup;
 	setup_udp_tunnel_sock(net, sock, &tuncfg);
 	net->sctp.udp6_sock = sock->sk;
 
-- 
2.1.0


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

* [PATCH net-next 08/15] sctp: add encap_port for netns sock asoc and transport
  2020-09-29 13:48             ` [PATCH net-next 07/15] sctp: add encap_err_lookup for udp encap socks Xin Long
  2020-09-29 13:48               ` Xin Long
@ 2020-09-29 13:49               ` Xin Long
  2020-09-29 13:49                 ` Xin Long
  2020-09-29 13:49                 ` [PATCH net-next 09/15] sctp: add SCTP_REMOTE_UDP_ENCAPS_PORT sockopt Xin Long
  1 sibling, 2 replies; 82+ messages in thread
From: Xin Long @ 2020-09-29 13:49 UTC (permalink / raw)
  To: network dev, linux-sctp
  Cc: Marcelo Ricardo Leitner, Neil Horman, Michael Tuexen, Tom Herbert, davem

encap_port is added as per netns/sock/assoc/transport, and the
latter one's encap_port inherits the former one's by default.
The transport's encap_port value would mostly decide if one
packet should go out with udp encaped or not.

This patch also allows users to set netns's encap_port by sysctl.

Signed-off-by: Xin Long <lucien.xin@gmail.com>
---
 include/net/netns/sctp.h   |  2 ++
 include/net/sctp/structs.h |  6 ++++++
 net/sctp/associola.c       |  4 ++++
 net/sctp/protocol.c        |  3 +++
 net/sctp/socket.c          |  1 +
 net/sctp/sysctl.c          | 10 ++++++++++
 6 files changed, 26 insertions(+)

diff --git a/include/net/netns/sctp.h b/include/net/netns/sctp.h
index f622945..6af7a39 100644
--- a/include/net/netns/sctp.h
+++ b/include/net/netns/sctp.h
@@ -27,6 +27,8 @@ struct netns_sctp {
 	struct sock *udp6_sock;
 	/* udp tunneling listening port. */
 	int udp_port;
+	/* udp tunneling remote encap port. */
+	int encap_port;
 
 	/* This is the global local address list.
 	 * We actively maintain this complete list of addresses on
diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h
index 0bdff38..b6d0e58 100644
--- a/include/net/sctp/structs.h
+++ b/include/net/sctp/structs.h
@@ -178,6 +178,8 @@ struct sctp_sock {
 	 */
 	__u32 hbinterval;
 
+	__u16 encap_port;
+
 	/* This is the max_retrans value for new associations. */
 	__u16 pathmaxrxt;
 
@@ -877,6 +879,8 @@ struct sctp_transport {
 	 */
 	unsigned long last_time_ecne_reduced;
 
+	__u16 encap_port;
+
 	/* This is the max_retrans value for the transport and will
 	 * be initialized from the assocs value.  This can be changed
 	 * using the SCTP_SET_PEER_ADDR_PARAMS socket option.
@@ -1790,6 +1794,8 @@ struct sctp_association {
 	 */
 	unsigned long hbinterval;
 
+	__u16 encap_port;
+
 	/* This is the max_retrans value for new transports in the
 	 * association.
 	 */
diff --git a/net/sctp/associola.c b/net/sctp/associola.c
index fdb69d4..336df4b 100644
--- a/net/sctp/associola.c
+++ b/net/sctp/associola.c
@@ -99,6 +99,8 @@ static struct sctp_association *sctp_association_init(
 	 */
 	asoc->hbinterval = msecs_to_jiffies(sp->hbinterval);
 
+	asoc->encap_port = sp->encap_port;
+
 	/* Initialize path max retrans value. */
 	asoc->pathmaxrxt = sp->pathmaxrxt;
 
@@ -624,6 +626,8 @@ struct sctp_transport *sctp_assoc_add_peer(struct sctp_association *asoc,
 	 */
 	peer->hbinterval = asoc->hbinterval;
 
+	peer->encap_port = asoc->encap_port;
+
 	/* Set the path max_retrans.  */
 	peer->pathmaxrxt = asoc->pathmaxrxt;
 
diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
index 953891b..8b788bd 100644
--- a/net/sctp/protocol.c
+++ b/net/sctp/protocol.c
@@ -1353,6 +1353,9 @@ static int __net_init sctp_defaults_init(struct net *net)
 	/* Set udp tunneling listening port to default value */
 	net->sctp.udp_port = SCTP_DEFAULT_UDP_PORT;
 
+	/* Set remote encap port to 0 by default */
+	net->sctp.encap_port = 0;
+
 	/* Set SCOPE policy to enabled */
 	net->sctp.scope_policy = SCTP_SCOPE_POLICY_ENABLE;
 
diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index 53d0a41..9aa0c3d 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -4876,6 +4876,7 @@ static int sctp_init_sock(struct sock *sk)
 	 * be modified via SCTP_PEER_ADDR_PARAMS
 	 */
 	sp->hbinterval  = net->sctp.hb_interval;
+	sp->encap_port  = net->sctp.encap_port;
 	sp->pathmaxrxt  = net->sctp.max_retrans_path;
 	sp->pf_retrans  = net->sctp.pf_retrans;
 	sp->ps_retrans  = net->sctp.ps_retrans;
diff --git a/net/sctp/sysctl.c b/net/sctp/sysctl.c
index c16c809..ecc1b5e 100644
--- a/net/sctp/sysctl.c
+++ b/net/sctp/sysctl.c
@@ -36,6 +36,7 @@ static int rto_alpha_max = 1000;
 static int rto_beta_max = 1000;
 static int pf_expose_max = SCTP_PF_EXPOSE_MAX;
 static int ps_retrans_max = SCTP_PS_RETRANS_MAX;
+static int udp_port_max = 65535;
 
 static unsigned long max_autoclose_min = 0;
 static unsigned long max_autoclose_max @@ -291,6 +292,15 @@ static struct ctl_table sctp_net_table[] = {
 		.proc_handler	= proc_dointvec,
 	},
 	{
+		.procname	= "encap_port",
+		.data		= &init_net.sctp.encap_port,
+		.maxlen		= sizeof(int),
+		.mode		= 0644,
+		.proc_handler	= proc_dointvec,
+		.extra1		= SYSCTL_ZERO,
+		.extra2		= &udp_port_max,
+	},
+	{
 		.procname	= "addr_scope_policy",
 		.data		= &init_net.sctp.scope_policy,
 		.maxlen		= sizeof(int),
-- 
2.1.0

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

* [PATCH net-next 08/15] sctp: add encap_port for netns sock asoc and transport
  2020-09-29 13:49               ` [PATCH net-next 08/15] sctp: add encap_port for netns sock asoc and transport Xin Long
@ 2020-09-29 13:49                 ` Xin Long
  2020-09-29 13:49                 ` [PATCH net-next 09/15] sctp: add SCTP_REMOTE_UDP_ENCAPS_PORT sockopt Xin Long
  1 sibling, 0 replies; 82+ messages in thread
From: Xin Long @ 2020-09-29 13:49 UTC (permalink / raw)
  To: network dev, linux-sctp
  Cc: Marcelo Ricardo Leitner, Neil Horman, Michael Tuexen, Tom Herbert, davem

encap_port is added as per netns/sock/assoc/transport, and the
latter one's encap_port inherits the former one's by default.
The transport's encap_port value would mostly decide if one
packet should go out with udp encaped or not.

This patch also allows users to set netns's encap_port by sysctl.

Signed-off-by: Xin Long <lucien.xin@gmail.com>
---
 include/net/netns/sctp.h   |  2 ++
 include/net/sctp/structs.h |  6 ++++++
 net/sctp/associola.c       |  4 ++++
 net/sctp/protocol.c        |  3 +++
 net/sctp/socket.c          |  1 +
 net/sctp/sysctl.c          | 10 ++++++++++
 6 files changed, 26 insertions(+)

diff --git a/include/net/netns/sctp.h b/include/net/netns/sctp.h
index f622945..6af7a39 100644
--- a/include/net/netns/sctp.h
+++ b/include/net/netns/sctp.h
@@ -27,6 +27,8 @@ struct netns_sctp {
 	struct sock *udp6_sock;
 	/* udp tunneling listening port. */
 	int udp_port;
+	/* udp tunneling remote encap port. */
+	int encap_port;
 
 	/* This is the global local address list.
 	 * We actively maintain this complete list of addresses on
diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h
index 0bdff38..b6d0e58 100644
--- a/include/net/sctp/structs.h
+++ b/include/net/sctp/structs.h
@@ -178,6 +178,8 @@ struct sctp_sock {
 	 */
 	__u32 hbinterval;
 
+	__u16 encap_port;
+
 	/* This is the max_retrans value for new associations. */
 	__u16 pathmaxrxt;
 
@@ -877,6 +879,8 @@ struct sctp_transport {
 	 */
 	unsigned long last_time_ecne_reduced;
 
+	__u16 encap_port;
+
 	/* This is the max_retrans value for the transport and will
 	 * be initialized from the assocs value.  This can be changed
 	 * using the SCTP_SET_PEER_ADDR_PARAMS socket option.
@@ -1790,6 +1794,8 @@ struct sctp_association {
 	 */
 	unsigned long hbinterval;
 
+	__u16 encap_port;
+
 	/* This is the max_retrans value for new transports in the
 	 * association.
 	 */
diff --git a/net/sctp/associola.c b/net/sctp/associola.c
index fdb69d4..336df4b 100644
--- a/net/sctp/associola.c
+++ b/net/sctp/associola.c
@@ -99,6 +99,8 @@ static struct sctp_association *sctp_association_init(
 	 */
 	asoc->hbinterval = msecs_to_jiffies(sp->hbinterval);
 
+	asoc->encap_port = sp->encap_port;
+
 	/* Initialize path max retrans value. */
 	asoc->pathmaxrxt = sp->pathmaxrxt;
 
@@ -624,6 +626,8 @@ struct sctp_transport *sctp_assoc_add_peer(struct sctp_association *asoc,
 	 */
 	peer->hbinterval = asoc->hbinterval;
 
+	peer->encap_port = asoc->encap_port;
+
 	/* Set the path max_retrans.  */
 	peer->pathmaxrxt = asoc->pathmaxrxt;
 
diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
index 953891b..8b788bd 100644
--- a/net/sctp/protocol.c
+++ b/net/sctp/protocol.c
@@ -1353,6 +1353,9 @@ static int __net_init sctp_defaults_init(struct net *net)
 	/* Set udp tunneling listening port to default value */
 	net->sctp.udp_port = SCTP_DEFAULT_UDP_PORT;
 
+	/* Set remote encap port to 0 by default */
+	net->sctp.encap_port = 0;
+
 	/* Set SCOPE policy to enabled */
 	net->sctp.scope_policy = SCTP_SCOPE_POLICY_ENABLE;
 
diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index 53d0a41..9aa0c3d 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -4876,6 +4876,7 @@ static int sctp_init_sock(struct sock *sk)
 	 * be modified via SCTP_PEER_ADDR_PARAMS
 	 */
 	sp->hbinterval  = net->sctp.hb_interval;
+	sp->encap_port  = net->sctp.encap_port;
 	sp->pathmaxrxt  = net->sctp.max_retrans_path;
 	sp->pf_retrans  = net->sctp.pf_retrans;
 	sp->ps_retrans  = net->sctp.ps_retrans;
diff --git a/net/sctp/sysctl.c b/net/sctp/sysctl.c
index c16c809..ecc1b5e 100644
--- a/net/sctp/sysctl.c
+++ b/net/sctp/sysctl.c
@@ -36,6 +36,7 @@ static int rto_alpha_max = 1000;
 static int rto_beta_max = 1000;
 static int pf_expose_max = SCTP_PF_EXPOSE_MAX;
 static int ps_retrans_max = SCTP_PS_RETRANS_MAX;
+static int udp_port_max = 65535;
 
 static unsigned long max_autoclose_min = 0;
 static unsigned long max_autoclose_max =
@@ -291,6 +292,15 @@ static struct ctl_table sctp_net_table[] = {
 		.proc_handler	= proc_dointvec,
 	},
 	{
+		.procname	= "encap_port",
+		.data		= &init_net.sctp.encap_port,
+		.maxlen		= sizeof(int),
+		.mode		= 0644,
+		.proc_handler	= proc_dointvec,
+		.extra1		= SYSCTL_ZERO,
+		.extra2		= &udp_port_max,
+	},
+	{
 		.procname	= "addr_scope_policy",
 		.data		= &init_net.sctp.scope_policy,
 		.maxlen		= sizeof(int),
-- 
2.1.0


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

* [PATCH net-next 09/15] sctp: add SCTP_REMOTE_UDP_ENCAPS_PORT sockopt
  2020-09-29 13:49               ` [PATCH net-next 08/15] sctp: add encap_port for netns sock asoc and transport Xin Long
  2020-09-29 13:49                 ` Xin Long
@ 2020-09-29 13:49                 ` Xin Long
  2020-09-29 13:49                   ` Xin Long
                                     ` (2 more replies)
  1 sibling, 3 replies; 82+ messages in thread
From: Xin Long @ 2020-09-29 13:49 UTC (permalink / raw)
  To: network dev, linux-sctp
  Cc: Marcelo Ricardo Leitner, Neil Horman, Michael Tuexen, Tom Herbert, davem

This patch is to implement:

  rfc6951#section-6.1: Get or Set the Remote UDP Encapsulation Port Number

with the param of the struct:

  struct sctp_udpencaps {
    sctp_assoc_t sue_assoc_id;
    struct sockaddr_storage sue_address;
    uint16_t sue_port;
  };

the encap_port of sock, assoc or transport can be changed by users,
which also means it allows the different transports of the same asoc
to have different encap_port value.

Signed-off-by: Xin Long <lucien.xin@gmail.com>
---
 include/uapi/linux/sctp.h |   7 +++
 net/sctp/socket.c         | 110 ++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 117 insertions(+)

diff --git a/include/uapi/linux/sctp.h b/include/uapi/linux/sctp.h
index 28ad40d..cb78e7a 100644
--- a/include/uapi/linux/sctp.h
+++ b/include/uapi/linux/sctp.h
@@ -140,6 +140,7 @@ typedef __s32 sctp_assoc_t;
 #define SCTP_ECN_SUPPORTED	130
 #define SCTP_EXPOSE_POTENTIALLY_FAILED_STATE	131
 #define SCTP_EXPOSE_PF_STATE	SCTP_EXPOSE_POTENTIALLY_FAILED_STATE
+#define SCTP_REMOTE_UDP_ENCAPS_PORT	132
 
 /* PR-SCTP policies */
 #define SCTP_PR_SCTP_NONE	0x0000
@@ -1197,6 +1198,12 @@ struct sctp_event {
 	uint8_t se_on;
 };
 
+struct sctp_udpencaps {
+	sctp_assoc_t sue_assoc_id;
+	struct sockaddr_storage sue_address;
+	uint16_t sue_port;
+};
+
 /* SCTP Stream schedulers */
 enum sctp_sched_type {
 	SCTP_SS_FCFS,
diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index 9aa0c3d..d793dfa9 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -4417,6 +4417,53 @@ static int sctp_setsockopt_pf_expose(struct sock *sk,
 	return retval;
 }
 
+static int sctp_setsockopt_encap_port(struct sock *sk,
+				      struct sctp_udpencaps *encap,
+				      unsigned int optlen)
+{
+	struct sctp_association *asoc;
+	struct sctp_transport *t;
+
+	if (optlen != sizeof(*encap))
+		return -EINVAL;
+
+	/* If an address other than INADDR_ANY is specified, and
+	 * no transport is found, then the request is invalid.
+	 */
+	if (!sctp_is_any(sk, (union sctp_addr *)&encap->sue_address)) {
+		t = sctp_addr_id2transport(sk, &encap->sue_address,
+					   encap->sue_assoc_id);
+		if (!t)
+			return -EINVAL;
+
+		t->encap_port = encap->sue_port;
+		return 0;
+	}
+
+	/* Get association, if assoc_id != SCTP_FUTURE_ASSOC and the
+	 * socket is a one to many style socket, and an association
+	 * was not found, then the id was invalid.
+	 */
+	asoc = sctp_id2assoc(sk, encap->sue_assoc_id);
+	if (!asoc && encap->sue_assoc_id != SCTP_FUTURE_ASSOC &&
+	    sctp_style(sk, UDP))
+		return -EINVAL;
+
+	/* If changes are for association, also apply encap to each
+	 * transport.
+	 */
+	if (asoc) {
+		list_for_each_entry(t, &asoc->peer.transport_addr_list,
+				    transports)
+			t->encap_port = encap->sue_port;
+
+		return 0;
+	}
+
+	sctp_sk(sk)->encap_port = encap->sue_port;
+	return 0;
+}
+
 /* API 6.2 setsockopt(), getsockopt()
  *
  * Applications use setsockopt() and getsockopt() to set or retrieve
@@ -4636,6 +4683,9 @@ static int sctp_setsockopt(struct sock *sk, int level, int optname,
 	case SCTP_EXPOSE_POTENTIALLY_FAILED_STATE:
 		retval = sctp_setsockopt_pf_expose(sk, kopt, optlen);
 		break;
+	case SCTP_REMOTE_UDP_ENCAPS_PORT:
+		retval = sctp_setsockopt_encap_port(sk, kopt, optlen);
+		break;
 	default:
 		retval = -ENOPROTOOPT;
 		break;
@@ -7791,6 +7841,63 @@ static int sctp_getsockopt_pf_expose(struct sock *sk, int len,
 	return retval;
 }
 
+static int sctp_getsockopt_encap_port(struct sock *sk, int len,
+				      char __user *optval, int __user *optlen)
+{
+	struct sctp_association *asoc;
+	struct sctp_udpencaps encap;
+	struct sctp_transport *t;
+
+	if (len < sizeof(encap))
+		return -EINVAL;
+
+	len = sizeof(encap);
+	if (copy_from_user(&encap, optval, len))
+		return -EFAULT;
+
+	/* If an address other than INADDR_ANY is specified, and
+	 * no transport is found, then the request is invalid.
+	 */
+	if (!sctp_is_any(sk, (union sctp_addr *)&encap.sue_address)) {
+		t = sctp_addr_id2transport(sk, &encap.sue_address,
+					   encap.sue_assoc_id);
+		if (!t) {
+			pr_debug("%s: failed no transport\n", __func__);
+			return -EINVAL;
+		}
+
+		encap.sue_port = t->encap_port;
+		goto out;
+	}
+
+	/* Get association, if assoc_id != SCTP_FUTURE_ASSOC and the
+	 * socket is a one to many style socket, and an association
+	 * was not found, then the id was invalid.
+	 */
+	asoc = sctp_id2assoc(sk, encap.sue_assoc_id);
+	if (!asoc && encap.sue_assoc_id != SCTP_FUTURE_ASSOC &&
+	    sctp_style(sk, UDP)) {
+		pr_debug("%s: failed no association\n", __func__);
+		return -EINVAL;
+	}
+
+	if (asoc) {
+		encap.sue_port = asoc->encap_port;
+		goto out;
+	}
+
+	encap.sue_port = sctp_sk(sk)->encap_port;
+
+out:
+	if (copy_to_user(optval, &encap, len))
+		return -EFAULT;
+
+	if (put_user(len, optlen))
+		return -EFAULT;
+
+	return 0;
+}
+
 static int sctp_getsockopt(struct sock *sk, int level, int optname,
 			   char __user *optval, int __user *optlen)
 {
@@ -8011,6 +8118,9 @@ static int sctp_getsockopt(struct sock *sk, int level, int optname,
 	case SCTP_EXPOSE_POTENTIALLY_FAILED_STATE:
 		retval = sctp_getsockopt_pf_expose(sk, len, optval, optlen);
 		break;
+	case SCTP_REMOTE_UDP_ENCAPS_PORT:
+		retval = sctp_getsockopt_encap_port(sk, len, optval, optlen);
+		break;
 	default:
 		retval = -ENOPROTOOPT;
 		break;
-- 
2.1.0

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

* [PATCH net-next 09/15] sctp: add SCTP_REMOTE_UDP_ENCAPS_PORT sockopt
  2020-09-29 13:49                 ` [PATCH net-next 09/15] sctp: add SCTP_REMOTE_UDP_ENCAPS_PORT sockopt Xin Long
@ 2020-09-29 13:49                   ` Xin Long
  2020-09-29 13:49                   ` [PATCH net-next 10/15] sctp: allow changing transport encap_port by peer packets Xin Long
  2020-10-03  4:05                   ` [PATCH net-next 09/15] sctp: add SCTP_REMOTE_UDP_ENCAPS_PORT sockopt Marcelo Ricardo Leitner
  2 siblings, 0 replies; 82+ messages in thread
From: Xin Long @ 2020-09-29 13:49 UTC (permalink / raw)
  To: network dev, linux-sctp
  Cc: Marcelo Ricardo Leitner, Neil Horman, Michael Tuexen, Tom Herbert, davem

This patch is to implement:

  rfc6951#section-6.1: Get or Set the Remote UDP Encapsulation Port Number

with the param of the struct:

  struct sctp_udpencaps {
    sctp_assoc_t sue_assoc_id;
    struct sockaddr_storage sue_address;
    uint16_t sue_port;
  };

the encap_port of sock, assoc or transport can be changed by users,
which also means it allows the different transports of the same asoc
to have different encap_port value.

Signed-off-by: Xin Long <lucien.xin@gmail.com>
---
 include/uapi/linux/sctp.h |   7 +++
 net/sctp/socket.c         | 110 ++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 117 insertions(+)

diff --git a/include/uapi/linux/sctp.h b/include/uapi/linux/sctp.h
index 28ad40d..cb78e7a 100644
--- a/include/uapi/linux/sctp.h
+++ b/include/uapi/linux/sctp.h
@@ -140,6 +140,7 @@ typedef __s32 sctp_assoc_t;
 #define SCTP_ECN_SUPPORTED	130
 #define SCTP_EXPOSE_POTENTIALLY_FAILED_STATE	131
 #define SCTP_EXPOSE_PF_STATE	SCTP_EXPOSE_POTENTIALLY_FAILED_STATE
+#define SCTP_REMOTE_UDP_ENCAPS_PORT	132
 
 /* PR-SCTP policies */
 #define SCTP_PR_SCTP_NONE	0x0000
@@ -1197,6 +1198,12 @@ struct sctp_event {
 	uint8_t se_on;
 };
 
+struct sctp_udpencaps {
+	sctp_assoc_t sue_assoc_id;
+	struct sockaddr_storage sue_address;
+	uint16_t sue_port;
+};
+
 /* SCTP Stream schedulers */
 enum sctp_sched_type {
 	SCTP_SS_FCFS,
diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index 9aa0c3d..d793dfa9 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -4417,6 +4417,53 @@ static int sctp_setsockopt_pf_expose(struct sock *sk,
 	return retval;
 }
 
+static int sctp_setsockopt_encap_port(struct sock *sk,
+				      struct sctp_udpencaps *encap,
+				      unsigned int optlen)
+{
+	struct sctp_association *asoc;
+	struct sctp_transport *t;
+
+	if (optlen != sizeof(*encap))
+		return -EINVAL;
+
+	/* If an address other than INADDR_ANY is specified, and
+	 * no transport is found, then the request is invalid.
+	 */
+	if (!sctp_is_any(sk, (union sctp_addr *)&encap->sue_address)) {
+		t = sctp_addr_id2transport(sk, &encap->sue_address,
+					   encap->sue_assoc_id);
+		if (!t)
+			return -EINVAL;
+
+		t->encap_port = encap->sue_port;
+		return 0;
+	}
+
+	/* Get association, if assoc_id != SCTP_FUTURE_ASSOC and the
+	 * socket is a one to many style socket, and an association
+	 * was not found, then the id was invalid.
+	 */
+	asoc = sctp_id2assoc(sk, encap->sue_assoc_id);
+	if (!asoc && encap->sue_assoc_id != SCTP_FUTURE_ASSOC &&
+	    sctp_style(sk, UDP))
+		return -EINVAL;
+
+	/* If changes are for association, also apply encap to each
+	 * transport.
+	 */
+	if (asoc) {
+		list_for_each_entry(t, &asoc->peer.transport_addr_list,
+				    transports)
+			t->encap_port = encap->sue_port;
+
+		return 0;
+	}
+
+	sctp_sk(sk)->encap_port = encap->sue_port;
+	return 0;
+}
+
 /* API 6.2 setsockopt(), getsockopt()
  *
  * Applications use setsockopt() and getsockopt() to set or retrieve
@@ -4636,6 +4683,9 @@ static int sctp_setsockopt(struct sock *sk, int level, int optname,
 	case SCTP_EXPOSE_POTENTIALLY_FAILED_STATE:
 		retval = sctp_setsockopt_pf_expose(sk, kopt, optlen);
 		break;
+	case SCTP_REMOTE_UDP_ENCAPS_PORT:
+		retval = sctp_setsockopt_encap_port(sk, kopt, optlen);
+		break;
 	default:
 		retval = -ENOPROTOOPT;
 		break;
@@ -7791,6 +7841,63 @@ static int sctp_getsockopt_pf_expose(struct sock *sk, int len,
 	return retval;
 }
 
+static int sctp_getsockopt_encap_port(struct sock *sk, int len,
+				      char __user *optval, int __user *optlen)
+{
+	struct sctp_association *asoc;
+	struct sctp_udpencaps encap;
+	struct sctp_transport *t;
+
+	if (len < sizeof(encap))
+		return -EINVAL;
+
+	len = sizeof(encap);
+	if (copy_from_user(&encap, optval, len))
+		return -EFAULT;
+
+	/* If an address other than INADDR_ANY is specified, and
+	 * no transport is found, then the request is invalid.
+	 */
+	if (!sctp_is_any(sk, (union sctp_addr *)&encap.sue_address)) {
+		t = sctp_addr_id2transport(sk, &encap.sue_address,
+					   encap.sue_assoc_id);
+		if (!t) {
+			pr_debug("%s: failed no transport\n", __func__);
+			return -EINVAL;
+		}
+
+		encap.sue_port = t->encap_port;
+		goto out;
+	}
+
+	/* Get association, if assoc_id != SCTP_FUTURE_ASSOC and the
+	 * socket is a one to many style socket, and an association
+	 * was not found, then the id was invalid.
+	 */
+	asoc = sctp_id2assoc(sk, encap.sue_assoc_id);
+	if (!asoc && encap.sue_assoc_id != SCTP_FUTURE_ASSOC &&
+	    sctp_style(sk, UDP)) {
+		pr_debug("%s: failed no association\n", __func__);
+		return -EINVAL;
+	}
+
+	if (asoc) {
+		encap.sue_port = asoc->encap_port;
+		goto out;
+	}
+
+	encap.sue_port = sctp_sk(sk)->encap_port;
+
+out:
+	if (copy_to_user(optval, &encap, len))
+		return -EFAULT;
+
+	if (put_user(len, optlen))
+		return -EFAULT;
+
+	return 0;
+}
+
 static int sctp_getsockopt(struct sock *sk, int level, int optname,
 			   char __user *optval, int __user *optlen)
 {
@@ -8011,6 +8118,9 @@ static int sctp_getsockopt(struct sock *sk, int level, int optname,
 	case SCTP_EXPOSE_POTENTIALLY_FAILED_STATE:
 		retval = sctp_getsockopt_pf_expose(sk, len, optval, optlen);
 		break;
+	case SCTP_REMOTE_UDP_ENCAPS_PORT:
+		retval = sctp_getsockopt_encap_port(sk, len, optval, optlen);
+		break;
 	default:
 		retval = -ENOPROTOOPT;
 		break;
-- 
2.1.0


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

* [PATCH net-next 10/15] sctp: allow changing transport encap_port by peer packets
  2020-09-29 13:49                 ` [PATCH net-next 09/15] sctp: add SCTP_REMOTE_UDP_ENCAPS_PORT sockopt Xin Long
  2020-09-29 13:49                   ` Xin Long
@ 2020-09-29 13:49                   ` Xin Long
  2020-09-29 13:49                     ` Xin Long
                                       ` (2 more replies)
  2020-10-03  4:05                   ` [PATCH net-next 09/15] sctp: add SCTP_REMOTE_UDP_ENCAPS_PORT sockopt Marcelo Ricardo Leitner
  2 siblings, 3 replies; 82+ messages in thread
From: Xin Long @ 2020-09-29 13:49 UTC (permalink / raw)
  To: network dev, linux-sctp
  Cc: Marcelo Ricardo Leitner, Neil Horman, Michael Tuexen, Tom Herbert, davem

As rfc6951#section-5.4 says:

  "After finding the SCTP association (which
   includes checking the verification tag), the UDP source port MUST be
   stored as the encapsulation port for the destination address the SCTP
   packet is received from (see Section 5.1).

   When a non-encapsulated SCTP packet is received by the SCTP stack,
   the encapsulation of outgoing packets belonging to the same
   association and the corresponding destination address MUST be
   disabled."

transport encap_port should be updated by a validated incoming packet's
udp src port.

We save the udp src port in sctp_input_cb->encap_port, and then update
the transport in two places:

  1. right after vtag is verified, which is required by RFC, and this
     allows the existent transports to be updated by the chunks that
     can only be processed on an asoc.

  2. right before processing the 'init' where the transports are added,
     and this allows building a sctp over udp connection by client with
     the server not knowing the remote encap port.

  3. when processing ootb_pkt and creating the temparory transport for
     the reply pkt.

Note that sctp_input_cb->header is removed, as it's not used any more
in sctp.

Signed-off-by: Xin Long <lucien.xin@gmail.com>
---
 include/net/sctp/sm.h      |  1 +
 include/net/sctp/structs.h |  7 +------
 net/sctp/ipv6.c            |  1 +
 net/sctp/protocol.c        | 11 ++++++++++-
 net/sctp/sm_make_chunk.c   |  1 +
 net/sctp/sm_statefuns.c    |  2 ++
 6 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/include/net/sctp/sm.h b/include/net/sctp/sm.h
index 5c491a3..a499341 100644
--- a/include/net/sctp/sm.h
+++ b/include/net/sctp/sm.h
@@ -380,6 +380,7 @@ sctp_vtag_verify(const struct sctp_chunk *chunk,
         if (ntohl(chunk->sctp_hdr->vtag) = asoc->c.my_vtag)
                 return 1;
 
+	chunk->transport->encap_port = SCTP_INPUT_CB(chunk->skb)->encap_port;
 	return 0;
 }
 
diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h
index b6d0e58..8819214 100644
--- a/include/net/sctp/structs.h
+++ b/include/net/sctp/structs.h
@@ -1120,14 +1120,9 @@ static inline void sctp_outq_cork(struct sctp_outq *q)
  * sctp_input_cb is currently used on rx and sock rx queue
  */
 struct sctp_input_cb {
-	union {
-		struct inet_skb_parm	h4;
-#if IS_ENABLED(CONFIG_IPV6)
-		struct inet6_skb_parm	h6;
-#endif
-	} header;
 	struct sctp_chunk *chunk;
 	struct sctp_af *af;
+	__u16 encap_port;
 };
 #define SCTP_INPUT_CB(__skb)	((struct sctp_input_cb *)&((__skb)->cb[0]))
 
diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c
index 8a58f42..a064bf2 100644
--- a/net/sctp/ipv6.c
+++ b/net/sctp/ipv6.c
@@ -1053,6 +1053,7 @@ static struct inet_protosw sctpv6_stream_protosw = {
 
 static int sctp6_rcv(struct sk_buff *skb)
 {
+	memset(skb->cb, 0, sizeof(skb->cb));
 	return sctp_rcv(skb) ? -1 : 0;
 }
 
diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
index 8b788bd..c73fd5f 100644
--- a/net/sctp/protocol.c
+++ b/net/sctp/protocol.c
@@ -842,6 +842,9 @@ static int sctp_ctl_sock_init(struct net *net)
 
 static int sctp_udp_rcv(struct sock *sk, struct sk_buff *skb)
 {
+	memset(skb->cb, 0, sizeof(skb->cb));
+	SCTP_INPUT_CB(skb)->encap_port = ntohs(udp_hdr(skb)->source);
+
 	skb_set_transport_header(skb, sizeof(struct udphdr));
 	sctp_rcv(skb);
 	return 0;
@@ -1133,9 +1136,15 @@ static struct inet_protosw sctp_stream_protosw = {
 	.flags      = SCTP_PROTOSW_FLAG
 };
 
+static int sctp4_rcv(struct sk_buff *skb)
+{
+	memset(skb->cb, 0, sizeof(skb->cb));
+	return sctp_rcv(skb);
+}
+
 /* Register with IP layer.  */
 static const struct net_protocol sctp_protocol = {
-	.handler     = sctp_rcv,
+	.handler     = sctp4_rcv,
 	.err_handler = sctp_v4_err,
 	.no_policy   = 1,
 	.netns_ok    = 1,
diff --git a/net/sctp/sm_make_chunk.c b/net/sctp/sm_make_chunk.c
index 9a56ae2..21d0ff1 100644
--- a/net/sctp/sm_make_chunk.c
+++ b/net/sctp/sm_make_chunk.c
@@ -2321,6 +2321,7 @@ int sctp_process_init(struct sctp_association *asoc, struct sctp_chunk *chunk,
 	 * added as the primary transport.  The source address seems to
 	 * be a better choice than any of the embedded addresses.
 	 */
+	asoc->encap_port = SCTP_INPUT_CB(chunk->skb)->encap_port;
 	if (!sctp_assoc_add_peer(asoc, peer_addr, gfp, SCTP_ACTIVE))
 		goto nomem;
 
diff --git a/net/sctp/sm_statefuns.c b/net/sctp/sm_statefuns.c
index c669f8b..8edab15 100644
--- a/net/sctp/sm_statefuns.c
+++ b/net/sctp/sm_statefuns.c
@@ -6268,6 +6268,8 @@ static struct sctp_packet *sctp_ootb_pkt_new(
 	if (!transport)
 		goto nomem;
 
+	transport->encap_port = SCTP_INPUT_CB(chunk->skb)->encap_port;
+
 	/* Cache a route for the transport with the chunk's destination as
 	 * the source address.
 	 */
-- 
2.1.0

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

* [PATCH net-next 10/15] sctp: allow changing transport encap_port by peer packets
  2020-09-29 13:49                   ` [PATCH net-next 10/15] sctp: allow changing transport encap_port by peer packets Xin Long
@ 2020-09-29 13:49                     ` Xin Long
  2020-09-29 13:49                     ` [PATCH net-next 11/15] sctp: add udphdr to overhead when udp_port is set Xin Long
  2020-10-03  4:06                     ` [PATCH net-next 10/15] sctp: allow changing transport encap_port by peer packets Marcelo Ricardo Leitner
  2 siblings, 0 replies; 82+ messages in thread
From: Xin Long @ 2020-09-29 13:49 UTC (permalink / raw)
  To: network dev, linux-sctp
  Cc: Marcelo Ricardo Leitner, Neil Horman, Michael Tuexen, Tom Herbert, davem

As rfc6951#section-5.4 says:

  "After finding the SCTP association (which
   includes checking the verification tag), the UDP source port MUST be
   stored as the encapsulation port for the destination address the SCTP
   packet is received from (see Section 5.1).

   When a non-encapsulated SCTP packet is received by the SCTP stack,
   the encapsulation of outgoing packets belonging to the same
   association and the corresponding destination address MUST be
   disabled."

transport encap_port should be updated by a validated incoming packet's
udp src port.

We save the udp src port in sctp_input_cb->encap_port, and then update
the transport in two places:

  1. right after vtag is verified, which is required by RFC, and this
     allows the existent transports to be updated by the chunks that
     can only be processed on an asoc.

  2. right before processing the 'init' where the transports are added,
     and this allows building a sctp over udp connection by client with
     the server not knowing the remote encap port.

  3. when processing ootb_pkt and creating the temparory transport for
     the reply pkt.

Note that sctp_input_cb->header is removed, as it's not used any more
in sctp.

Signed-off-by: Xin Long <lucien.xin@gmail.com>
---
 include/net/sctp/sm.h      |  1 +
 include/net/sctp/structs.h |  7 +------
 net/sctp/ipv6.c            |  1 +
 net/sctp/protocol.c        | 11 ++++++++++-
 net/sctp/sm_make_chunk.c   |  1 +
 net/sctp/sm_statefuns.c    |  2 ++
 6 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/include/net/sctp/sm.h b/include/net/sctp/sm.h
index 5c491a3..a499341 100644
--- a/include/net/sctp/sm.h
+++ b/include/net/sctp/sm.h
@@ -380,6 +380,7 @@ sctp_vtag_verify(const struct sctp_chunk *chunk,
         if (ntohl(chunk->sctp_hdr->vtag) == asoc->c.my_vtag)
                 return 1;
 
+	chunk->transport->encap_port = SCTP_INPUT_CB(chunk->skb)->encap_port;
 	return 0;
 }
 
diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h
index b6d0e58..8819214 100644
--- a/include/net/sctp/structs.h
+++ b/include/net/sctp/structs.h
@@ -1120,14 +1120,9 @@ static inline void sctp_outq_cork(struct sctp_outq *q)
  * sctp_input_cb is currently used on rx and sock rx queue
  */
 struct sctp_input_cb {
-	union {
-		struct inet_skb_parm	h4;
-#if IS_ENABLED(CONFIG_IPV6)
-		struct inet6_skb_parm	h6;
-#endif
-	} header;
 	struct sctp_chunk *chunk;
 	struct sctp_af *af;
+	__u16 encap_port;
 };
 #define SCTP_INPUT_CB(__skb)	((struct sctp_input_cb *)&((__skb)->cb[0]))
 
diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c
index 8a58f42..a064bf2 100644
--- a/net/sctp/ipv6.c
+++ b/net/sctp/ipv6.c
@@ -1053,6 +1053,7 @@ static struct inet_protosw sctpv6_stream_protosw = {
 
 static int sctp6_rcv(struct sk_buff *skb)
 {
+	memset(skb->cb, 0, sizeof(skb->cb));
 	return sctp_rcv(skb) ? -1 : 0;
 }
 
diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
index 8b788bd..c73fd5f 100644
--- a/net/sctp/protocol.c
+++ b/net/sctp/protocol.c
@@ -842,6 +842,9 @@ static int sctp_ctl_sock_init(struct net *net)
 
 static int sctp_udp_rcv(struct sock *sk, struct sk_buff *skb)
 {
+	memset(skb->cb, 0, sizeof(skb->cb));
+	SCTP_INPUT_CB(skb)->encap_port = ntohs(udp_hdr(skb)->source);
+
 	skb_set_transport_header(skb, sizeof(struct udphdr));
 	sctp_rcv(skb);
 	return 0;
@@ -1133,9 +1136,15 @@ static struct inet_protosw sctp_stream_protosw = {
 	.flags      = SCTP_PROTOSW_FLAG
 };
 
+static int sctp4_rcv(struct sk_buff *skb)
+{
+	memset(skb->cb, 0, sizeof(skb->cb));
+	return sctp_rcv(skb);
+}
+
 /* Register with IP layer.  */
 static const struct net_protocol sctp_protocol = {
-	.handler     = sctp_rcv,
+	.handler     = sctp4_rcv,
 	.err_handler = sctp_v4_err,
 	.no_policy   = 1,
 	.netns_ok    = 1,
diff --git a/net/sctp/sm_make_chunk.c b/net/sctp/sm_make_chunk.c
index 9a56ae2..21d0ff1 100644
--- a/net/sctp/sm_make_chunk.c
+++ b/net/sctp/sm_make_chunk.c
@@ -2321,6 +2321,7 @@ int sctp_process_init(struct sctp_association *asoc, struct sctp_chunk *chunk,
 	 * added as the primary transport.  The source address seems to
 	 * be a better choice than any of the embedded addresses.
 	 */
+	asoc->encap_port = SCTP_INPUT_CB(chunk->skb)->encap_port;
 	if (!sctp_assoc_add_peer(asoc, peer_addr, gfp, SCTP_ACTIVE))
 		goto nomem;
 
diff --git a/net/sctp/sm_statefuns.c b/net/sctp/sm_statefuns.c
index c669f8b..8edab15 100644
--- a/net/sctp/sm_statefuns.c
+++ b/net/sctp/sm_statefuns.c
@@ -6268,6 +6268,8 @@ static struct sctp_packet *sctp_ootb_pkt_new(
 	if (!transport)
 		goto nomem;
 
+	transport->encap_port = SCTP_INPUT_CB(chunk->skb)->encap_port;
+
 	/* Cache a route for the transport with the chunk's destination as
 	 * the source address.
 	 */
-- 
2.1.0


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

* [PATCH net-next 11/15] sctp: add udphdr to overhead when udp_port is set
  2020-09-29 13:49                   ` [PATCH net-next 10/15] sctp: allow changing transport encap_port by peer packets Xin Long
  2020-09-29 13:49                     ` Xin Long
@ 2020-09-29 13:49                     ` Xin Long
  2020-09-29 13:49                       ` Xin Long
                                         ` (3 more replies)
  2020-10-03  4:06                     ` [PATCH net-next 10/15] sctp: allow changing transport encap_port by peer packets Marcelo Ricardo Leitner
  2 siblings, 4 replies; 82+ messages in thread
From: Xin Long @ 2020-09-29 13:49 UTC (permalink / raw)
  To: network dev, linux-sctp
  Cc: Marcelo Ricardo Leitner, Neil Horman, Michael Tuexen, Tom Herbert, davem

sctp_mtu_payload() is for calculating the frag size before making
chunks from a msg. So we should only add udphdr size to overhead
when udp socks are listening, as only then sctp can handling the
incoming sctp over udp packets and outgoing sctp over udp packets
will be possible.

Note that we can't do this according to transport->encap_port, as
different transports may be set to different values, while the
chunks were made before choosing the transport, we could not be
able to meet all rfc6951#section-5.6 requires.

Signed-off-by: Xin Long <lucien.xin@gmail.com>
---
 include/net/sctp/sctp.h | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/include/net/sctp/sctp.h b/include/net/sctp/sctp.h
index bfd87a0..6408bbb 100644
--- a/include/net/sctp/sctp.h
+++ b/include/net/sctp/sctp.h
@@ -578,10 +578,13 @@ static inline __u32 sctp_mtu_payload(const struct sctp_sock *sp,
 {
 	__u32 overhead = sizeof(struct sctphdr) + extra;
 
-	if (sp)
+	if (sp) {
 		overhead += sp->pf->af->net_header_len;
-	else
+		if (sock_net(&sp->inet.sk)->sctp.udp_port)
+			overhead += sizeof(struct udphdr);
+	} else {
 		overhead += sizeof(struct ipv6hdr);
+	}
 
 	if (WARN_ON_ONCE(mtu && mtu <= overhead))
 		mtu = overhead;
-- 
2.1.0

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

* [PATCH net-next 11/15] sctp: add udphdr to overhead when udp_port is set
  2020-09-29 13:49                     ` [PATCH net-next 11/15] sctp: add udphdr to overhead when udp_port is set Xin Long
@ 2020-09-29 13:49                       ` Xin Long
  2020-09-29 13:49                       ` [PATCH net-next 12/15] sctp: call sk_setup_caps in sctp_packet_transmit instead Xin Long
                                         ` (2 subsequent siblings)
  3 siblings, 0 replies; 82+ messages in thread
From: Xin Long @ 2020-09-29 13:49 UTC (permalink / raw)
  To: network dev, linux-sctp
  Cc: Marcelo Ricardo Leitner, Neil Horman, Michael Tuexen, Tom Herbert, davem

sctp_mtu_payload() is for calculating the frag size before making
chunks from a msg. So we should only add udphdr size to overhead
when udp socks are listening, as only then sctp can handling the
incoming sctp over udp packets and outgoing sctp over udp packets
will be possible.

Note that we can't do this according to transport->encap_port, as
different transports may be set to different values, while the
chunks were made before choosing the transport, we could not be
able to meet all rfc6951#section-5.6 requires.

Signed-off-by: Xin Long <lucien.xin@gmail.com>
---
 include/net/sctp/sctp.h | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/include/net/sctp/sctp.h b/include/net/sctp/sctp.h
index bfd87a0..6408bbb 100644
--- a/include/net/sctp/sctp.h
+++ b/include/net/sctp/sctp.h
@@ -578,10 +578,13 @@ static inline __u32 sctp_mtu_payload(const struct sctp_sock *sp,
 {
 	__u32 overhead = sizeof(struct sctphdr) + extra;
 
-	if (sp)
+	if (sp) {
 		overhead += sp->pf->af->net_header_len;
-	else
+		if (sock_net(&sp->inet.sk)->sctp.udp_port)
+			overhead += sizeof(struct udphdr);
+	} else {
 		overhead += sizeof(struct ipv6hdr);
+	}
 
 	if (WARN_ON_ONCE(mtu && mtu <= overhead))
 		mtu = overhead;
-- 
2.1.0


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

* [PATCH net-next 12/15] sctp: call sk_setup_caps in sctp_packet_transmit instead
  2020-09-29 13:49                     ` [PATCH net-next 11/15] sctp: add udphdr to overhead when udp_port is set Xin Long
  2020-09-29 13:49                       ` Xin Long
@ 2020-09-29 13:49                       ` Xin Long
  2020-09-29 13:49                         ` Xin Long
                                           ` (2 more replies)
  2020-09-29 19:00                       ` [PATCH net-next 11/15] sctp: add udphdr to overhead when udp_port is set kernel test robot
  2020-10-03  4:07                       ` Marcelo Ricardo Leitner
  3 siblings, 3 replies; 82+ messages in thread
From: Xin Long @ 2020-09-29 13:49 UTC (permalink / raw)
  To: network dev, linux-sctp
  Cc: Marcelo Ricardo Leitner, Neil Horman, Michael Tuexen, Tom Herbert, davem

sk_setup_caps() was originally called in Commit 90017accff61 ("sctp:
Add GSO support"), as:

  "We have to refresh this in case we are xmiting to more than one
   transport at a time"

This actually happens in the loop of sctp_outq_flush_transports(),
and it shouldn't be gso related, so move it out of gso part and
before sctp_packet_pack().

Signed-off-by: Xin Long <lucien.xin@gmail.com>
---
 net/sctp/output.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/net/sctp/output.c b/net/sctp/output.c
index 1441eaf..fb16500 100644
--- a/net/sctp/output.c
+++ b/net/sctp/output.c
@@ -508,12 +508,6 @@ static int sctp_packet_pack(struct sctp_packet *packet,
 					sizeof(struct inet6_skb_parm)));
 		skb_shinfo(head)->gso_segs = pkt_count;
 		skb_shinfo(head)->gso_size = GSO_BY_FRAGS;
-		rcu_read_lock();
-		if (skb_dst(head) != tp->dst) {
-			dst_hold(tp->dst);
-			sk_setup_caps(sk, tp->dst);
-		}
-		rcu_read_unlock();
 		goto chksum;
 	}
 
@@ -593,6 +587,13 @@ int sctp_packet_transmit(struct sctp_packet *packet, gfp_t gfp)
 	}
 	skb_dst_set(head, dst);
 
+	rcu_read_lock();
+	if (__sk_dst_get(sk) != tp->dst) {
+		dst_hold(tp->dst);
+		sk_setup_caps(sk, tp->dst);
+	}
+	rcu_read_unlock();
+
 	/* pack up chunks */
 	pkt_count = sctp_packet_pack(packet, head, gso, gfp);
 	if (!pkt_count) {
-- 
2.1.0

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

* [PATCH net-next 12/15] sctp: call sk_setup_caps in sctp_packet_transmit instead
  2020-09-29 13:49                       ` [PATCH net-next 12/15] sctp: call sk_setup_caps in sctp_packet_transmit instead Xin Long
@ 2020-09-29 13:49                         ` Xin Long
  2020-09-29 13:49                         ` [PATCH net-next 13/15] sctp: support for sending packet over udp4 sock Xin Long
  2020-10-03  4:09                         ` [PATCH net-next 12/15] sctp: call sk_setup_caps in sctp_packet_transmit instead Marcelo Ricardo Leitner
  2 siblings, 0 replies; 82+ messages in thread
From: Xin Long @ 2020-09-29 13:49 UTC (permalink / raw)
  To: network dev, linux-sctp
  Cc: Marcelo Ricardo Leitner, Neil Horman, Michael Tuexen, Tom Herbert, davem

sk_setup_caps() was originally called in Commit 90017accff61 ("sctp:
Add GSO support"), as:

  "We have to refresh this in case we are xmiting to more than one
   transport at a time"

This actually happens in the loop of sctp_outq_flush_transports(),
and it shouldn't be gso related, so move it out of gso part and
before sctp_packet_pack().

Signed-off-by: Xin Long <lucien.xin@gmail.com>
---
 net/sctp/output.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/net/sctp/output.c b/net/sctp/output.c
index 1441eaf..fb16500 100644
--- a/net/sctp/output.c
+++ b/net/sctp/output.c
@@ -508,12 +508,6 @@ static int sctp_packet_pack(struct sctp_packet *packet,
 					sizeof(struct inet6_skb_parm)));
 		skb_shinfo(head)->gso_segs = pkt_count;
 		skb_shinfo(head)->gso_size = GSO_BY_FRAGS;
-		rcu_read_lock();
-		if (skb_dst(head) != tp->dst) {
-			dst_hold(tp->dst);
-			sk_setup_caps(sk, tp->dst);
-		}
-		rcu_read_unlock();
 		goto chksum;
 	}
 
@@ -593,6 +587,13 @@ int sctp_packet_transmit(struct sctp_packet *packet, gfp_t gfp)
 	}
 	skb_dst_set(head, dst);
 
+	rcu_read_lock();
+	if (__sk_dst_get(sk) != tp->dst) {
+		dst_hold(tp->dst);
+		sk_setup_caps(sk, tp->dst);
+	}
+	rcu_read_unlock();
+
 	/* pack up chunks */
 	pkt_count = sctp_packet_pack(packet, head, gso, gfp);
 	if (!pkt_count) {
-- 
2.1.0


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

* [PATCH net-next 13/15] sctp: support for sending packet over udp4 sock
  2020-09-29 13:49                       ` [PATCH net-next 12/15] sctp: call sk_setup_caps in sctp_packet_transmit instead Xin Long
  2020-09-29 13:49                         ` Xin Long
@ 2020-09-29 13:49                         ` Xin Long
  2020-09-29 13:49                           ` Xin Long
                                             ` (3 more replies)
  2020-10-03  4:09                         ` [PATCH net-next 12/15] sctp: call sk_setup_caps in sctp_packet_transmit instead Marcelo Ricardo Leitner
  2 siblings, 4 replies; 82+ messages in thread
From: Xin Long @ 2020-09-29 13:49 UTC (permalink / raw)
  To: network dev, linux-sctp
  Cc: Marcelo Ricardo Leitner, Neil Horman, Michael Tuexen, Tom Herbert, davem

This patch does what the rfc6951#section-5.3 says for ipv4:

  "Within the UDP header, the source port MUST be the local UDP
   encapsulation port number of the SCTP stack, and the destination port
   MUST be the remote UDP encapsulation port number maintained for the
   association and the destination address to which the packet is sent
   (see Section 5.1).

   Because the SCTP packet is the UDP payload, the length of the UDP
   packet MUST be the length of the SCTP packet plus the size of the UDP
   header.

   The SCTP checksum MUST be computed for IPv4 and IPv6, and the UDP
   checksum SHOULD be computed for IPv4 and IPv6."

Some places need to be adjusted in sctp_packet_transmit():

  1. For non-gso packets, when transport's encap_port is set, sctp
     checksum has to be done in sctp_packet_pack(), as the outer
     udp will use ip_summed = CHECKSUM_PARTIAL to do the offload
     setting for checksum.

  2. Delay calling dst_clone() and skb_dst_set() for non-udp packets
     until sctp_v4_xmit(), as for udp packets, skb_dst_set() is not
     needed before calling udp_tunnel_xmit_skb().

then in sctp_v4_xmit():

  1. Go to udp_tunnel_xmit_skb() only when transport->encap_port and
     net->sctp.udp_port both are set, as these are one for dst port
     and another for src port.

  2. For gso packet, SKB_GSO_UDP_TUNNEL_CSUM is set for gso_type, and
     with this udp checksum can be done in __skb_udp_tunnel_segment()
     for each segments after the sctp gso.

  3. inner_mac_header and inner_transport_header are set, as these
     will be needed in __skb_udp_tunnel_segment() to find the right
     headers.

  4. df and ttl are calculated, as these are the required params by
     udp_tunnel_xmit_skb().

  5. nocheck param has to be false, as "the UDP checksum SHOULD be
     computed for IPv4 and IPv6", says in rfc6951#section-5.3.

Signed-off-by: Xin Long <lucien.xin@gmail.com>
---
 net/sctp/output.c   |  9 +++------
 net/sctp/protocol.c | 44 +++++++++++++++++++++++++++++++++-----------
 2 files changed, 36 insertions(+), 17 deletions(-)

diff --git a/net/sctp/output.c b/net/sctp/output.c
index fb16500..6614c9f 100644
--- a/net/sctp/output.c
+++ b/net/sctp/output.c
@@ -514,8 +514,8 @@ static int sctp_packet_pack(struct sctp_packet *packet,
 	if (sctp_checksum_disable)
 		return 1;
 
-	if (!(skb_dst(head)->dev->features & NETIF_F_SCTP_CRC) ||
-	    dst_xfrm(skb_dst(head)) || packet->ipfragok) {
+	if (!(tp->dst->dev->features & NETIF_F_SCTP_CRC) ||
+	    dst_xfrm(tp->dst) || packet->ipfragok || tp->encap_port) {
 		struct sctphdr *sh  			(struct sctphdr *)skb_transport_header(head);
 
@@ -542,7 +542,6 @@ int sctp_packet_transmit(struct sctp_packet *packet, gfp_t gfp)
 	struct sctp_association *asoc = tp->asoc;
 	struct sctp_chunk *chunk, *tmp;
 	int pkt_count, gso = 0;
-	struct dst_entry *dst;
 	struct sk_buff *head;
 	struct sctphdr *sh;
 	struct sock *sk;
@@ -579,13 +578,11 @@ int sctp_packet_transmit(struct sctp_packet *packet, gfp_t gfp)
 	sh->checksum = 0;
 
 	/* drop packet if no dst */
-	dst = dst_clone(tp->dst);
-	if (!dst) {
+	if (!tp->dst) {
 		IP_INC_STATS(sock_net(sk), IPSTATS_MIB_OUTNOROUTES);
 		kfree_skb(head);
 		goto out;
 	}
-	skb_dst_set(head, dst);
 
 	rcu_read_lock();
 	if (__sk_dst_get(sk) != tp->dst) {
diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
index c73fd5f..6606a63 100644
--- a/net/sctp/protocol.c
+++ b/net/sctp/protocol.c
@@ -44,6 +44,7 @@
 #include <net/addrconf.h>
 #include <net/inet_common.h>
 #include <net/inet_ecn.h>
+#include <net/udp_tunnel.h>
 
 #define MAX_SCTP_PORT_HASH_ENTRIES (64 * 1024)
 
@@ -1053,25 +1054,46 @@ static int sctp_inet_supported_addrs(const struct sctp_sock *opt,
 }
 
 /* Wrapper routine that calls the ip transmit routine. */
-static inline int sctp_v4_xmit(struct sk_buff *skb,
-			       struct sctp_transport *transport)
+static inline int sctp_v4_xmit(struct sk_buff *skb, struct sctp_transport *t)
 {
-	struct inet_sock *inet = inet_sk(skb->sk);
+	struct dst_entry *dst = dst_clone(t->dst);
+	struct flowi4 *fl4 = &t->fl.u.ip4;
+	struct sock *sk = skb->sk;
+	struct inet_sock *inet = inet_sk(sk);
+	struct net *net = sock_net(sk);
 	__u8 dscp = inet->tos;
+	__be16 df = 0;
 
 	pr_debug("%s: skb:%p, len:%d, src:%pI4, dst:%pI4\n", __func__, skb,
-		 skb->len, &transport->fl.u.ip4.saddr,
-		 &transport->fl.u.ip4.daddr);
+		 skb->len, &fl4->saddr, &fl4->daddr);
+
+	if (t->dscp & SCTP_DSCP_SET_MASK)
+		dscp = t->dscp & SCTP_DSCP_VAL_MASK;
 
-	if (transport->dscp & SCTP_DSCP_SET_MASK)
-		dscp = transport->dscp & SCTP_DSCP_VAL_MASK;
+	inet->pmtudisc = t->param_flags & SPP_PMTUD_ENABLE ? IP_PMTUDISC_DO
+							   : IP_PMTUDISC_DONT;
+	SCTP_INC_STATS(net, SCTP_MIB_OUTSCTPPACKS);
 
-	inet->pmtudisc = transport->param_flags & SPP_PMTUD_ENABLE ?
-			 IP_PMTUDISC_DO : IP_PMTUDISC_DONT;
+	if (!t->encap_port || !net->sctp.udp_port) {
+		skb_dst_set(skb, dst);
+		return __ip_queue_xmit(sk, skb, &t->fl, dscp);
+	}
+
+	if (skb_is_gso(skb))
+		skb_shinfo(skb)->gso_type |= SKB_GSO_UDP_TUNNEL_CSUM;
 
-	SCTP_INC_STATS(sock_net(&inet->sk), SCTP_MIB_OUTSCTPPACKS);
+	if (ip_dont_fragment(sk, dst) && !skb->ignore_df)
+		df = htons(IP_DF);
 
-	return __ip_queue_xmit(&inet->sk, skb, &transport->fl, dscp);
+	skb->encapsulation = 1;
+	skb_reset_inner_mac_header(skb);
+	skb_reset_inner_transport_header(skb);
+	skb_set_inner_ipproto(skb, IPPROTO_SCTP);
+	udp_tunnel_xmit_skb((struct rtable *)dst, sk, skb, fl4->saddr,
+			    fl4->daddr, dscp, ip4_dst_hoplimit(dst), df,
+			    htons(net->sctp.udp_port), htons(t->encap_port),
+			    false, false);
+	return 0;
 }
 
 static struct sctp_af sctp_af_inet;
-- 
2.1.0

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

* [PATCH net-next 13/15] sctp: support for sending packet over udp4 sock
  2020-09-29 13:49                         ` [PATCH net-next 13/15] sctp: support for sending packet over udp4 sock Xin Long
@ 2020-09-29 13:49                           ` Xin Long
  2020-09-29 13:49                           ` [PATCH net-next 14/15] sctp: support for sending packet over udp6 sock Xin Long
                                             ` (2 subsequent siblings)
  3 siblings, 0 replies; 82+ messages in thread
From: Xin Long @ 2020-09-29 13:49 UTC (permalink / raw)
  To: network dev, linux-sctp
  Cc: Marcelo Ricardo Leitner, Neil Horman, Michael Tuexen, Tom Herbert, davem

This patch does what the rfc6951#section-5.3 says for ipv4:

  "Within the UDP header, the source port MUST be the local UDP
   encapsulation port number of the SCTP stack, and the destination port
   MUST be the remote UDP encapsulation port number maintained for the
   association and the destination address to which the packet is sent
   (see Section 5.1).

   Because the SCTP packet is the UDP payload, the length of the UDP
   packet MUST be the length of the SCTP packet plus the size of the UDP
   header.

   The SCTP checksum MUST be computed for IPv4 and IPv6, and the UDP
   checksum SHOULD be computed for IPv4 and IPv6."

Some places need to be adjusted in sctp_packet_transmit():

  1. For non-gso packets, when transport's encap_port is set, sctp
     checksum has to be done in sctp_packet_pack(), as the outer
     udp will use ip_summed = CHECKSUM_PARTIAL to do the offload
     setting for checksum.

  2. Delay calling dst_clone() and skb_dst_set() for non-udp packets
     until sctp_v4_xmit(), as for udp packets, skb_dst_set() is not
     needed before calling udp_tunnel_xmit_skb().

then in sctp_v4_xmit():

  1. Go to udp_tunnel_xmit_skb() only when transport->encap_port and
     net->sctp.udp_port both are set, as these are one for dst port
     and another for src port.

  2. For gso packet, SKB_GSO_UDP_TUNNEL_CSUM is set for gso_type, and
     with this udp checksum can be done in __skb_udp_tunnel_segment()
     for each segments after the sctp gso.

  3. inner_mac_header and inner_transport_header are set, as these
     will be needed in __skb_udp_tunnel_segment() to find the right
     headers.

  4. df and ttl are calculated, as these are the required params by
     udp_tunnel_xmit_skb().

  5. nocheck param has to be false, as "the UDP checksum SHOULD be
     computed for IPv4 and IPv6", says in rfc6951#section-5.3.

Signed-off-by: Xin Long <lucien.xin@gmail.com>
---
 net/sctp/output.c   |  9 +++------
 net/sctp/protocol.c | 44 +++++++++++++++++++++++++++++++++-----------
 2 files changed, 36 insertions(+), 17 deletions(-)

diff --git a/net/sctp/output.c b/net/sctp/output.c
index fb16500..6614c9f 100644
--- a/net/sctp/output.c
+++ b/net/sctp/output.c
@@ -514,8 +514,8 @@ static int sctp_packet_pack(struct sctp_packet *packet,
 	if (sctp_checksum_disable)
 		return 1;
 
-	if (!(skb_dst(head)->dev->features & NETIF_F_SCTP_CRC) ||
-	    dst_xfrm(skb_dst(head)) || packet->ipfragok) {
+	if (!(tp->dst->dev->features & NETIF_F_SCTP_CRC) ||
+	    dst_xfrm(tp->dst) || packet->ipfragok || tp->encap_port) {
 		struct sctphdr *sh =
 			(struct sctphdr *)skb_transport_header(head);
 
@@ -542,7 +542,6 @@ int sctp_packet_transmit(struct sctp_packet *packet, gfp_t gfp)
 	struct sctp_association *asoc = tp->asoc;
 	struct sctp_chunk *chunk, *tmp;
 	int pkt_count, gso = 0;
-	struct dst_entry *dst;
 	struct sk_buff *head;
 	struct sctphdr *sh;
 	struct sock *sk;
@@ -579,13 +578,11 @@ int sctp_packet_transmit(struct sctp_packet *packet, gfp_t gfp)
 	sh->checksum = 0;
 
 	/* drop packet if no dst */
-	dst = dst_clone(tp->dst);
-	if (!dst) {
+	if (!tp->dst) {
 		IP_INC_STATS(sock_net(sk), IPSTATS_MIB_OUTNOROUTES);
 		kfree_skb(head);
 		goto out;
 	}
-	skb_dst_set(head, dst);
 
 	rcu_read_lock();
 	if (__sk_dst_get(sk) != tp->dst) {
diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
index c73fd5f..6606a63 100644
--- a/net/sctp/protocol.c
+++ b/net/sctp/protocol.c
@@ -44,6 +44,7 @@
 #include <net/addrconf.h>
 #include <net/inet_common.h>
 #include <net/inet_ecn.h>
+#include <net/udp_tunnel.h>
 
 #define MAX_SCTP_PORT_HASH_ENTRIES (64 * 1024)
 
@@ -1053,25 +1054,46 @@ static int sctp_inet_supported_addrs(const struct sctp_sock *opt,
 }
 
 /* Wrapper routine that calls the ip transmit routine. */
-static inline int sctp_v4_xmit(struct sk_buff *skb,
-			       struct sctp_transport *transport)
+static inline int sctp_v4_xmit(struct sk_buff *skb, struct sctp_transport *t)
 {
-	struct inet_sock *inet = inet_sk(skb->sk);
+	struct dst_entry *dst = dst_clone(t->dst);
+	struct flowi4 *fl4 = &t->fl.u.ip4;
+	struct sock *sk = skb->sk;
+	struct inet_sock *inet = inet_sk(sk);
+	struct net *net = sock_net(sk);
 	__u8 dscp = inet->tos;
+	__be16 df = 0;
 
 	pr_debug("%s: skb:%p, len:%d, src:%pI4, dst:%pI4\n", __func__, skb,
-		 skb->len, &transport->fl.u.ip4.saddr,
-		 &transport->fl.u.ip4.daddr);
+		 skb->len, &fl4->saddr, &fl4->daddr);
+
+	if (t->dscp & SCTP_DSCP_SET_MASK)
+		dscp = t->dscp & SCTP_DSCP_VAL_MASK;
 
-	if (transport->dscp & SCTP_DSCP_SET_MASK)
-		dscp = transport->dscp & SCTP_DSCP_VAL_MASK;
+	inet->pmtudisc = t->param_flags & SPP_PMTUD_ENABLE ? IP_PMTUDISC_DO
+							   : IP_PMTUDISC_DONT;
+	SCTP_INC_STATS(net, SCTP_MIB_OUTSCTPPACKS);
 
-	inet->pmtudisc = transport->param_flags & SPP_PMTUD_ENABLE ?
-			 IP_PMTUDISC_DO : IP_PMTUDISC_DONT;
+	if (!t->encap_port || !net->sctp.udp_port) {
+		skb_dst_set(skb, dst);
+		return __ip_queue_xmit(sk, skb, &t->fl, dscp);
+	}
+
+	if (skb_is_gso(skb))
+		skb_shinfo(skb)->gso_type |= SKB_GSO_UDP_TUNNEL_CSUM;
 
-	SCTP_INC_STATS(sock_net(&inet->sk), SCTP_MIB_OUTSCTPPACKS);
+	if (ip_dont_fragment(sk, dst) && !skb->ignore_df)
+		df = htons(IP_DF);
 
-	return __ip_queue_xmit(&inet->sk, skb, &transport->fl, dscp);
+	skb->encapsulation = 1;
+	skb_reset_inner_mac_header(skb);
+	skb_reset_inner_transport_header(skb);
+	skb_set_inner_ipproto(skb, IPPROTO_SCTP);
+	udp_tunnel_xmit_skb((struct rtable *)dst, sk, skb, fl4->saddr,
+			    fl4->daddr, dscp, ip4_dst_hoplimit(dst), df,
+			    htons(net->sctp.udp_port), htons(t->encap_port),
+			    false, false);
+	return 0;
 }
 
 static struct sctp_af sctp_af_inet;
-- 
2.1.0


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

* [PATCH net-next 14/15] sctp: support for sending packet over udp6 sock
  2020-09-29 13:49                         ` [PATCH net-next 13/15] sctp: support for sending packet over udp4 sock Xin Long
  2020-09-29 13:49                           ` Xin Long
@ 2020-09-29 13:49                           ` Xin Long
  2020-09-29 13:49                             ` Xin Long
  2020-09-29 13:49                             ` [PATCH net-next 15/15] sctp: enable udp tunneling socks Xin Long
  2020-09-29 16:25                           ` [PATCH net-next 13/15] sctp: support for sending packet over udp4 sock kernel test robot
  2020-09-29 19:19                           ` kernel test robot
  3 siblings, 2 replies; 82+ messages in thread
From: Xin Long @ 2020-09-29 13:49 UTC (permalink / raw)
  To: network dev, linux-sctp
  Cc: Marcelo Ricardo Leitner, Neil Horman, Michael Tuexen, Tom Herbert, davem

This one basically does the similar things in sctp_v6_xmit as does for
udp4 sock in the last patch, just note that:

  1. label needs to be calculated, as it's the param of
     udp_tunnel6_xmit_skb().

  2. The 'nocheck' param of udp_tunnel6_xmit_skb() is false, as
     required by RFC.

Signed-off-by: Xin Long <lucien.xin@gmail.com>
---
 net/sctp/ipv6.c | 47 +++++++++++++++++++++++++++++++++++------------
 1 file changed, 35 insertions(+), 12 deletions(-)

diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c
index a064bf2..5c831f3 100644
--- a/net/sctp/ipv6.c
+++ b/net/sctp/ipv6.c
@@ -55,6 +55,7 @@
 #include <net/inet_common.h>
 #include <net/inet_ecn.h>
 #include <net/sctp/sctp.h>
+#include <net/udp_tunnel.h>
 
 #include <linux/uaccess.h>
 
@@ -191,33 +192,55 @@ static int sctp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
 	return ret;
 }
 
-static int sctp_v6_xmit(struct sk_buff *skb, struct sctp_transport *transport)
+static int sctp_v6_xmit(struct sk_buff *skb, struct sctp_transport *t)
 {
+	struct dst_entry *dst = dst_clone(t->dst);
+	struct flowi6 *fl6 = &t->fl.u.ip6;
 	struct sock *sk = skb->sk;
 	struct ipv6_pinfo *np = inet6_sk(sk);
-	struct flowi6 *fl6 = &transport->fl.u.ip6;
+	struct net *net = sock_net(sk);
 	__u8 tclass = np->tclass;
-	int res;
+	__be32 label;
 
 	pr_debug("%s: skb:%p, len:%d, src:%pI6 dst:%pI6\n", __func__, skb,
 		 skb->len, &fl6->saddr, &fl6->daddr);
 
-	if (transport->dscp & SCTP_DSCP_SET_MASK)
-		tclass = transport->dscp & SCTP_DSCP_VAL_MASK;
+	if (t->dscp & SCTP_DSCP_SET_MASK)
+		tclass = t->dscp & SCTP_DSCP_VAL_MASK;
 
 	if (INET_ECN_is_capable(tclass))
 		IP6_ECN_flow_xmit(sk, fl6->flowlabel);
 
-	if (!(transport->param_flags & SPP_PMTUD_ENABLE))
+	if (!(t->param_flags & SPP_PMTUD_ENABLE))
 		skb->ignore_df = 1;
 
-	SCTP_INC_STATS(sock_net(sk), SCTP_MIB_OUTSCTPPACKS);
+	SCTP_INC_STATS(net, SCTP_MIB_OUTSCTPPACKS);
 
-	rcu_read_lock();
-	res = ip6_xmit(sk, skb, fl6, sk->sk_mark, rcu_dereference(np->opt),
-		       tclass, sk->sk_priority);
-	rcu_read_unlock();
-	return res;
+	if (!t->encap_port || !net->sctp.udp_port) {
+		int res;
+
+		skb_dst_set(skb, dst);
+		rcu_read_lock();
+		res = ip6_xmit(sk, skb, fl6, sk->sk_mark,
+			       rcu_dereference(np->opt),
+			       tclass, sk->sk_priority);
+		rcu_read_unlock();
+		return res;
+	}
+
+	if (skb_is_gso(skb))
+		skb_shinfo(skb)->gso_type |= SKB_GSO_UDP_TUNNEL_CSUM;
+
+	skb->encapsulation = 1;
+	skb_reset_inner_mac_header(skb);
+	skb_reset_inner_transport_header(skb);
+	skb_set_inner_ipproto(skb, IPPROTO_SCTP);
+	label = ip6_make_flowlabel(net, skb, fl6->flowlabel, true, fl6);
+
+	return udp_tunnel6_xmit_skb(dst, sk, skb, NULL, &fl6->saddr,
+				    &fl6->daddr, tclass, ip6_dst_hoplimit(dst),
+				    label, htons(net->sctp.udp_port),
+				    htons(t->encap_port), false);
 }
 
 /* Returns the dst cache entry for the given source and destination ip
-- 
2.1.0

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

* [PATCH net-next 14/15] sctp: support for sending packet over udp6 sock
  2020-09-29 13:49                           ` [PATCH net-next 14/15] sctp: support for sending packet over udp6 sock Xin Long
@ 2020-09-29 13:49                             ` Xin Long
  2020-09-29 13:49                             ` [PATCH net-next 15/15] sctp: enable udp tunneling socks Xin Long
  1 sibling, 0 replies; 82+ messages in thread
From: Xin Long @ 2020-09-29 13:49 UTC (permalink / raw)
  To: network dev, linux-sctp
  Cc: Marcelo Ricardo Leitner, Neil Horman, Michael Tuexen, Tom Herbert, davem

This one basically does the similar things in sctp_v6_xmit as does for
udp4 sock in the last patch, just note that:

  1. label needs to be calculated, as it's the param of
     udp_tunnel6_xmit_skb().

  2. The 'nocheck' param of udp_tunnel6_xmit_skb() is false, as
     required by RFC.

Signed-off-by: Xin Long <lucien.xin@gmail.com>
---
 net/sctp/ipv6.c | 47 +++++++++++++++++++++++++++++++++++------------
 1 file changed, 35 insertions(+), 12 deletions(-)

diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c
index a064bf2..5c831f3 100644
--- a/net/sctp/ipv6.c
+++ b/net/sctp/ipv6.c
@@ -55,6 +55,7 @@
 #include <net/inet_common.h>
 #include <net/inet_ecn.h>
 #include <net/sctp/sctp.h>
+#include <net/udp_tunnel.h>
 
 #include <linux/uaccess.h>
 
@@ -191,33 +192,55 @@ static int sctp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
 	return ret;
 }
 
-static int sctp_v6_xmit(struct sk_buff *skb, struct sctp_transport *transport)
+static int sctp_v6_xmit(struct sk_buff *skb, struct sctp_transport *t)
 {
+	struct dst_entry *dst = dst_clone(t->dst);
+	struct flowi6 *fl6 = &t->fl.u.ip6;
 	struct sock *sk = skb->sk;
 	struct ipv6_pinfo *np = inet6_sk(sk);
-	struct flowi6 *fl6 = &transport->fl.u.ip6;
+	struct net *net = sock_net(sk);
 	__u8 tclass = np->tclass;
-	int res;
+	__be32 label;
 
 	pr_debug("%s: skb:%p, len:%d, src:%pI6 dst:%pI6\n", __func__, skb,
 		 skb->len, &fl6->saddr, &fl6->daddr);
 
-	if (transport->dscp & SCTP_DSCP_SET_MASK)
-		tclass = transport->dscp & SCTP_DSCP_VAL_MASK;
+	if (t->dscp & SCTP_DSCP_SET_MASK)
+		tclass = t->dscp & SCTP_DSCP_VAL_MASK;
 
 	if (INET_ECN_is_capable(tclass))
 		IP6_ECN_flow_xmit(sk, fl6->flowlabel);
 
-	if (!(transport->param_flags & SPP_PMTUD_ENABLE))
+	if (!(t->param_flags & SPP_PMTUD_ENABLE))
 		skb->ignore_df = 1;
 
-	SCTP_INC_STATS(sock_net(sk), SCTP_MIB_OUTSCTPPACKS);
+	SCTP_INC_STATS(net, SCTP_MIB_OUTSCTPPACKS);
 
-	rcu_read_lock();
-	res = ip6_xmit(sk, skb, fl6, sk->sk_mark, rcu_dereference(np->opt),
-		       tclass, sk->sk_priority);
-	rcu_read_unlock();
-	return res;
+	if (!t->encap_port || !net->sctp.udp_port) {
+		int res;
+
+		skb_dst_set(skb, dst);
+		rcu_read_lock();
+		res = ip6_xmit(sk, skb, fl6, sk->sk_mark,
+			       rcu_dereference(np->opt),
+			       tclass, sk->sk_priority);
+		rcu_read_unlock();
+		return res;
+	}
+
+	if (skb_is_gso(skb))
+		skb_shinfo(skb)->gso_type |= SKB_GSO_UDP_TUNNEL_CSUM;
+
+	skb->encapsulation = 1;
+	skb_reset_inner_mac_header(skb);
+	skb_reset_inner_transport_header(skb);
+	skb_set_inner_ipproto(skb, IPPROTO_SCTP);
+	label = ip6_make_flowlabel(net, skb, fl6->flowlabel, true, fl6);
+
+	return udp_tunnel6_xmit_skb(dst, sk, skb, NULL, &fl6->saddr,
+				    &fl6->daddr, tclass, ip6_dst_hoplimit(dst),
+				    label, htons(net->sctp.udp_port),
+				    htons(t->encap_port), false);
 }
 
 /* Returns the dst cache entry for the given source and destination ip
-- 
2.1.0


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

* [PATCH net-next 15/15] sctp: enable udp tunneling socks
  2020-09-29 13:49                           ` [PATCH net-next 14/15] sctp: support for sending packet over udp6 sock Xin Long
  2020-09-29 13:49                             ` Xin Long
@ 2020-09-29 13:49                             ` Xin Long
  2020-09-29 13:49                               ` Xin Long
  2020-10-03  4:12                               ` Marcelo Ricardo Leitner
  1 sibling, 2 replies; 82+ messages in thread
From: Xin Long @ 2020-09-29 13:49 UTC (permalink / raw)
  To: network dev, linux-sctp
  Cc: Marcelo Ricardo Leitner, Neil Horman, Michael Tuexen, Tom Herbert, davem

This patch is to enable udp tunneling socks by calling
sctp_udp_sock_start() in sctp_ctrlsock_init(), and
sctp_udp_sock_stop() in sctp_ctrlsock_exit().

Also add sysctl udp_port to allow changing the listening
sock's port by users.

Wit this patch, the whole sctp over udp feature can be
enabled and used.

Signed-off-by: Xin Long <lucien.xin@gmail.com>
---
 net/sctp/protocol.c |  5 +++++
 net/sctp/sysctl.c   | 43 +++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 48 insertions(+)

diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
index 6606a63..4b63883 100644
--- a/net/sctp/protocol.c
+++ b/net/sctp/protocol.c
@@ -1466,6 +1466,10 @@ static int __net_init sctp_ctrlsock_init(struct net *net)
 	if (status)
 		pr_err("Failed to initialize the SCTP control sock\n");
 
+	status = sctp_udp_sock_start(net);
+	if (status)
+		pr_err("Failed to initialize the SCTP udp tunneling sock\n");
+
 	return status;
 }
 
@@ -1473,6 +1477,7 @@ static void __net_exit sctp_ctrlsock_exit(struct net *net)
 {
 	/* Free the control endpoint.  */
 	inet_ctl_sock_destroy(net->sctp.ctl_sock);
+	sctp_udp_sock_stop(net);
 }
 
 static struct pernet_operations sctp_ctrlsock_ops = {
diff --git a/net/sctp/sysctl.c b/net/sctp/sysctl.c
index ecc1b5e..7afe904 100644
--- a/net/sctp/sysctl.c
+++ b/net/sctp/sysctl.c
@@ -49,6 +49,8 @@ static int proc_sctp_do_rto_min(struct ctl_table *ctl, int write,
 				void *buffer, size_t *lenp, loff_t *ppos);
 static int proc_sctp_do_rto_max(struct ctl_table *ctl, int write, void *buffer,
 				size_t *lenp, loff_t *ppos);
+static int proc_sctp_do_udp_port(struct ctl_table *ctl, int write, void *buffer,
+				 size_t *lenp, loff_t *ppos);
 static int proc_sctp_do_alpha_beta(struct ctl_table *ctl, int write,
 				   void *buffer, size_t *lenp, loff_t *ppos);
 static int proc_sctp_do_auth(struct ctl_table *ctl, int write,
@@ -292,6 +294,15 @@ static struct ctl_table sctp_net_table[] = {
 		.proc_handler	= proc_dointvec,
 	},
 	{
+		.procname	= "udp_port",
+		.data		= &init_net.sctp.udp_port,
+		.maxlen		= sizeof(int),
+		.mode		= 0644,
+		.proc_handler	= proc_sctp_do_udp_port,
+		.extra1		= SYSCTL_ZERO,
+		.extra2		= &udp_port_max,
+	},
+	{
 		.procname	= "encap_port",
 		.data		= &init_net.sctp.encap_port,
 		.maxlen		= sizeof(int),
@@ -487,6 +498,38 @@ static int proc_sctp_do_auth(struct ctl_table *ctl, int write,
 	return ret;
 }
 
+static int proc_sctp_do_udp_port(struct ctl_table *ctl, int write,
+				 void *buffer, size_t *lenp, loff_t *ppos)
+{
+	struct net *net = current->nsproxy->net_ns;
+	unsigned int min = *(unsigned int *)ctl->extra1;
+	unsigned int max = *(unsigned int *)ctl->extra2;
+	struct ctl_table tbl;
+	int ret, new_value;
+
+	memset(&tbl, 0, sizeof(struct ctl_table));
+	tbl.maxlen = sizeof(unsigned int);
+
+	if (write)
+		tbl.data = &new_value;
+	else
+		tbl.data = &net->sctp.udp_port;
+
+	ret = proc_dointvec(&tbl, write, buffer, lenp, ppos);
+	if (write && ret = 0) {
+		if (new_value > max || new_value < min)
+			return -EINVAL;
+
+		net->sctp.udp_port = new_value;
+		sctp_udp_sock_stop(net);
+		ret = sctp_udp_sock_start(net);
+		if (ret)
+			net->sctp.udp_port = 0;
+	}
+
+	return ret;
+}
+
 int sctp_sysctl_net_register(struct net *net)
 {
 	struct ctl_table *table;
-- 
2.1.0

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

* [PATCH net-next 15/15] sctp: enable udp tunneling socks
  2020-09-29 13:49                             ` [PATCH net-next 15/15] sctp: enable udp tunneling socks Xin Long
@ 2020-09-29 13:49                               ` Xin Long
  2020-10-03  4:12                               ` Marcelo Ricardo Leitner
  1 sibling, 0 replies; 82+ messages in thread
From: Xin Long @ 2020-09-29 13:49 UTC (permalink / raw)
  To: network dev, linux-sctp
  Cc: Marcelo Ricardo Leitner, Neil Horman, Michael Tuexen, Tom Herbert, davem

This patch is to enable udp tunneling socks by calling
sctp_udp_sock_start() in sctp_ctrlsock_init(), and
sctp_udp_sock_stop() in sctp_ctrlsock_exit().

Also add sysctl udp_port to allow changing the listening
sock's port by users.

Wit this patch, the whole sctp over udp feature can be
enabled and used.

Signed-off-by: Xin Long <lucien.xin@gmail.com>
---
 net/sctp/protocol.c |  5 +++++
 net/sctp/sysctl.c   | 43 +++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 48 insertions(+)

diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
index 6606a63..4b63883 100644
--- a/net/sctp/protocol.c
+++ b/net/sctp/protocol.c
@@ -1466,6 +1466,10 @@ static int __net_init sctp_ctrlsock_init(struct net *net)
 	if (status)
 		pr_err("Failed to initialize the SCTP control sock\n");
 
+	status = sctp_udp_sock_start(net);
+	if (status)
+		pr_err("Failed to initialize the SCTP udp tunneling sock\n");
+
 	return status;
 }
 
@@ -1473,6 +1477,7 @@ static void __net_exit sctp_ctrlsock_exit(struct net *net)
 {
 	/* Free the control endpoint.  */
 	inet_ctl_sock_destroy(net->sctp.ctl_sock);
+	sctp_udp_sock_stop(net);
 }
 
 static struct pernet_operations sctp_ctrlsock_ops = {
diff --git a/net/sctp/sysctl.c b/net/sctp/sysctl.c
index ecc1b5e..7afe904 100644
--- a/net/sctp/sysctl.c
+++ b/net/sctp/sysctl.c
@@ -49,6 +49,8 @@ static int proc_sctp_do_rto_min(struct ctl_table *ctl, int write,
 				void *buffer, size_t *lenp, loff_t *ppos);
 static int proc_sctp_do_rto_max(struct ctl_table *ctl, int write, void *buffer,
 				size_t *lenp, loff_t *ppos);
+static int proc_sctp_do_udp_port(struct ctl_table *ctl, int write, void *buffer,
+				 size_t *lenp, loff_t *ppos);
 static int proc_sctp_do_alpha_beta(struct ctl_table *ctl, int write,
 				   void *buffer, size_t *lenp, loff_t *ppos);
 static int proc_sctp_do_auth(struct ctl_table *ctl, int write,
@@ -292,6 +294,15 @@ static struct ctl_table sctp_net_table[] = {
 		.proc_handler	= proc_dointvec,
 	},
 	{
+		.procname	= "udp_port",
+		.data		= &init_net.sctp.udp_port,
+		.maxlen		= sizeof(int),
+		.mode		= 0644,
+		.proc_handler	= proc_sctp_do_udp_port,
+		.extra1		= SYSCTL_ZERO,
+		.extra2		= &udp_port_max,
+	},
+	{
 		.procname	= "encap_port",
 		.data		= &init_net.sctp.encap_port,
 		.maxlen		= sizeof(int),
@@ -487,6 +498,38 @@ static int proc_sctp_do_auth(struct ctl_table *ctl, int write,
 	return ret;
 }
 
+static int proc_sctp_do_udp_port(struct ctl_table *ctl, int write,
+				 void *buffer, size_t *lenp, loff_t *ppos)
+{
+	struct net *net = current->nsproxy->net_ns;
+	unsigned int min = *(unsigned int *)ctl->extra1;
+	unsigned int max = *(unsigned int *)ctl->extra2;
+	struct ctl_table tbl;
+	int ret, new_value;
+
+	memset(&tbl, 0, sizeof(struct ctl_table));
+	tbl.maxlen = sizeof(unsigned int);
+
+	if (write)
+		tbl.data = &new_value;
+	else
+		tbl.data = &net->sctp.udp_port;
+
+	ret = proc_dointvec(&tbl, write, buffer, lenp, ppos);
+	if (write && ret == 0) {
+		if (new_value > max || new_value < min)
+			return -EINVAL;
+
+		net->sctp.udp_port = new_value;
+		sctp_udp_sock_stop(net);
+		ret = sctp_udp_sock_start(net);
+		if (ret)
+			net->sctp.udp_port = 0;
+	}
+
+	return ret;
+}
+
 int sctp_sysctl_net_register(struct net *net)
 {
 	struct ctl_table *table;
-- 
2.1.0


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

* Re: [PATCH net-next 13/15] sctp: support for sending packet over udp4 sock
  2020-09-29 13:49                         ` [PATCH net-next 13/15] sctp: support for sending packet over udp4 sock Xin Long
  2020-09-29 13:49                           ` Xin Long
  2020-09-29 13:49                           ` [PATCH net-next 14/15] sctp: support for sending packet over udp6 sock Xin Long
@ 2020-09-29 16:25                           ` kernel test robot
  2020-09-29 16:25                             ` kernel test robot
  2020-09-30  6:26                             ` Xin Long
  2020-09-29 19:19                           ` kernel test robot
  3 siblings, 2 replies; 82+ messages in thread
From: kernel test robot @ 2020-09-29 16:25 UTC (permalink / raw)
  To: Xin Long, network dev, linux-sctp
  Cc: kbuild-all, Marcelo Ricardo Leitner, Neil Horman, Michael Tuexen,
	Tom Herbert, davem

[-- Attachment #1: Type: text/plain, Size: 4610 bytes --]

Hi Xin,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on net-next/master]

url:    https://github.com/0day-ci/linux/commits/Xin-Long/sctp-Implement-RFC6951-UDP-Encapsulation-of-SCTP/20200929-215159
base:   https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git 280095713ce244e8dbdfb059cdca695baa72230a
config: ia64-randconfig-r014-20200929 (attached as .config)
compiler: ia64-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/a1016fd4a55f176fcc2eae05052a61ad7d5a142b
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Xin-Long/sctp-Implement-RFC6951-UDP-Encapsulation-of-SCTP/20200929-215159
        git checkout a1016fd4a55f176fcc2eae05052a61ad7d5a142b
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=ia64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   net/sctp/protocol.c: In function 'sctp_udp_sock_start':
>> net/sctp/protocol.c:894:11: error: 'struct udp_port_cfg' has no member named 'local_ip6'; did you mean 'local_ip'?
     894 |  udp_conf.local_ip6 = in6addr_any;
         |           ^~~~~~~~~
         |           local_ip

vim +894 net/sctp/protocol.c

a330bee1c278f8 Xin Long 2020-09-29  870  
140bb5309cf409 Xin Long 2020-09-29  871  int sctp_udp_sock_start(struct net *net)
140bb5309cf409 Xin Long 2020-09-29  872  {
140bb5309cf409 Xin Long 2020-09-29  873  	struct udp_tunnel_sock_cfg tuncfg = {NULL};
140bb5309cf409 Xin Long 2020-09-29  874  	struct udp_port_cfg udp_conf = {0};
140bb5309cf409 Xin Long 2020-09-29  875  	struct socket *sock;
140bb5309cf409 Xin Long 2020-09-29  876  	int err;
140bb5309cf409 Xin Long 2020-09-29  877  
140bb5309cf409 Xin Long 2020-09-29  878  	udp_conf.family = AF_INET;
140bb5309cf409 Xin Long 2020-09-29  879  	udp_conf.local_ip.s_addr = htonl(INADDR_ANY);
140bb5309cf409 Xin Long 2020-09-29  880  	udp_conf.local_udp_port = htons(net->sctp.udp_port);
140bb5309cf409 Xin Long 2020-09-29  881  	err = udp_sock_create(net, &udp_conf, &sock);
140bb5309cf409 Xin Long 2020-09-29  882  	if (err)
140bb5309cf409 Xin Long 2020-09-29  883  		return err;
140bb5309cf409 Xin Long 2020-09-29  884  
140bb5309cf409 Xin Long 2020-09-29  885  	tuncfg.encap_type = 1;
140bb5309cf409 Xin Long 2020-09-29  886  	tuncfg.encap_rcv = sctp_udp_rcv;
a330bee1c278f8 Xin Long 2020-09-29  887  	tuncfg.encap_err_lookup = sctp_udp_err_lookup;
140bb5309cf409 Xin Long 2020-09-29  888  	setup_udp_tunnel_sock(net, sock, &tuncfg);
140bb5309cf409 Xin Long 2020-09-29  889  	net->sctp.udp4_sock = sock->sk;
140bb5309cf409 Xin Long 2020-09-29  890  
cff8956126170d Xin Long 2020-09-29  891  	memset(&udp_conf, 0, sizeof(udp_conf));
cff8956126170d Xin Long 2020-09-29  892  
cff8956126170d Xin Long 2020-09-29  893  	udp_conf.family = AF_INET6;
cff8956126170d Xin Long 2020-09-29 @894  	udp_conf.local_ip6 = in6addr_any;
cff8956126170d Xin Long 2020-09-29  895  	udp_conf.local_udp_port = htons(net->sctp.udp_port);
cff8956126170d Xin Long 2020-09-29  896  	udp_conf.use_udp6_rx_checksums = true;
cff8956126170d Xin Long 2020-09-29  897  	udp_conf.ipv6_v6only = true;
cff8956126170d Xin Long 2020-09-29  898  	err = udp_sock_create(net, &udp_conf, &sock);
cff8956126170d Xin Long 2020-09-29  899  	if (err) {
cff8956126170d Xin Long 2020-09-29  900  		udp_tunnel_sock_release(net->sctp.udp4_sock->sk_socket);
cff8956126170d Xin Long 2020-09-29  901  		net->sctp.udp4_sock = NULL;
cff8956126170d Xin Long 2020-09-29  902  		return err;
cff8956126170d Xin Long 2020-09-29  903  	}
cff8956126170d Xin Long 2020-09-29  904  
cff8956126170d Xin Long 2020-09-29  905  	tuncfg.encap_type = 1;
cff8956126170d Xin Long 2020-09-29  906  	tuncfg.encap_rcv = sctp_udp_rcv;
a330bee1c278f8 Xin Long 2020-09-29  907  	tuncfg.encap_err_lookup = sctp_udp_err_lookup;
cff8956126170d Xin Long 2020-09-29  908  	setup_udp_tunnel_sock(net, sock, &tuncfg);
cff8956126170d Xin Long 2020-09-29  909  	net->sctp.udp6_sock = sock->sk;
cff8956126170d Xin Long 2020-09-29  910  
140bb5309cf409 Xin Long 2020-09-29  911  	return 0;
140bb5309cf409 Xin Long 2020-09-29  912  }
140bb5309cf409 Xin Long 2020-09-29  913  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 31654 bytes --]

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

* Re: [PATCH net-next 13/15] sctp: support for sending packet over udp4 sock
  2020-09-29 16:25                           ` [PATCH net-next 13/15] sctp: support for sending packet over udp4 sock kernel test robot
@ 2020-09-29 16:25                             ` kernel test robot
  2020-09-30  6:26                             ` Xin Long
  1 sibling, 0 replies; 82+ messages in thread
From: kernel test robot @ 2020-09-29 16:25 UTC (permalink / raw)
  To: Xin Long, network dev, linux-sctp
  Cc: kbuild-all, Marcelo Ricardo Leitner, Neil Horman, Michael Tuexen,
	Tom Herbert, davem

[-- Attachment #1: Type: text/plain, Size: 4610 bytes --]

Hi Xin,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on net-next/master]

url:    https://github.com/0day-ci/linux/commits/Xin-Long/sctp-Implement-RFC6951-UDP-Encapsulation-of-SCTP/20200929-215159
base:   https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git 280095713ce244e8dbdfb059cdca695baa72230a
config: ia64-randconfig-r014-20200929 (attached as .config)
compiler: ia64-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/a1016fd4a55f176fcc2eae05052a61ad7d5a142b
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Xin-Long/sctp-Implement-RFC6951-UDP-Encapsulation-of-SCTP/20200929-215159
        git checkout a1016fd4a55f176fcc2eae05052a61ad7d5a142b
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=ia64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   net/sctp/protocol.c: In function 'sctp_udp_sock_start':
>> net/sctp/protocol.c:894:11: error: 'struct udp_port_cfg' has no member named 'local_ip6'; did you mean 'local_ip'?
     894 |  udp_conf.local_ip6 = in6addr_any;
         |           ^~~~~~~~~
         |           local_ip

vim +894 net/sctp/protocol.c

a330bee1c278f8 Xin Long 2020-09-29  870  
140bb5309cf409 Xin Long 2020-09-29  871  int sctp_udp_sock_start(struct net *net)
140bb5309cf409 Xin Long 2020-09-29  872  {
140bb5309cf409 Xin Long 2020-09-29  873  	struct udp_tunnel_sock_cfg tuncfg = {NULL};
140bb5309cf409 Xin Long 2020-09-29  874  	struct udp_port_cfg udp_conf = {0};
140bb5309cf409 Xin Long 2020-09-29  875  	struct socket *sock;
140bb5309cf409 Xin Long 2020-09-29  876  	int err;
140bb5309cf409 Xin Long 2020-09-29  877  
140bb5309cf409 Xin Long 2020-09-29  878  	udp_conf.family = AF_INET;
140bb5309cf409 Xin Long 2020-09-29  879  	udp_conf.local_ip.s_addr = htonl(INADDR_ANY);
140bb5309cf409 Xin Long 2020-09-29  880  	udp_conf.local_udp_port = htons(net->sctp.udp_port);
140bb5309cf409 Xin Long 2020-09-29  881  	err = udp_sock_create(net, &udp_conf, &sock);
140bb5309cf409 Xin Long 2020-09-29  882  	if (err)
140bb5309cf409 Xin Long 2020-09-29  883  		return err;
140bb5309cf409 Xin Long 2020-09-29  884  
140bb5309cf409 Xin Long 2020-09-29  885  	tuncfg.encap_type = 1;
140bb5309cf409 Xin Long 2020-09-29  886  	tuncfg.encap_rcv = sctp_udp_rcv;
a330bee1c278f8 Xin Long 2020-09-29  887  	tuncfg.encap_err_lookup = sctp_udp_err_lookup;
140bb5309cf409 Xin Long 2020-09-29  888  	setup_udp_tunnel_sock(net, sock, &tuncfg);
140bb5309cf409 Xin Long 2020-09-29  889  	net->sctp.udp4_sock = sock->sk;
140bb5309cf409 Xin Long 2020-09-29  890  
cff8956126170d Xin Long 2020-09-29  891  	memset(&udp_conf, 0, sizeof(udp_conf));
cff8956126170d Xin Long 2020-09-29  892  
cff8956126170d Xin Long 2020-09-29  893  	udp_conf.family = AF_INET6;
cff8956126170d Xin Long 2020-09-29 @894  	udp_conf.local_ip6 = in6addr_any;
cff8956126170d Xin Long 2020-09-29  895  	udp_conf.local_udp_port = htons(net->sctp.udp_port);
cff8956126170d Xin Long 2020-09-29  896  	udp_conf.use_udp6_rx_checksums = true;
cff8956126170d Xin Long 2020-09-29  897  	udp_conf.ipv6_v6only = true;
cff8956126170d Xin Long 2020-09-29  898  	err = udp_sock_create(net, &udp_conf, &sock);
cff8956126170d Xin Long 2020-09-29  899  	if (err) {
cff8956126170d Xin Long 2020-09-29  900  		udp_tunnel_sock_release(net->sctp.udp4_sock->sk_socket);
cff8956126170d Xin Long 2020-09-29  901  		net->sctp.udp4_sock = NULL;
cff8956126170d Xin Long 2020-09-29  902  		return err;
cff8956126170d Xin Long 2020-09-29  903  	}
cff8956126170d Xin Long 2020-09-29  904  
cff8956126170d Xin Long 2020-09-29  905  	tuncfg.encap_type = 1;
cff8956126170d Xin Long 2020-09-29  906  	tuncfg.encap_rcv = sctp_udp_rcv;
a330bee1c278f8 Xin Long 2020-09-29  907  	tuncfg.encap_err_lookup = sctp_udp_err_lookup;
cff8956126170d Xin Long 2020-09-29  908  	setup_udp_tunnel_sock(net, sock, &tuncfg);
cff8956126170d Xin Long 2020-09-29  909  	net->sctp.udp6_sock = sock->sk;
cff8956126170d Xin Long 2020-09-29  910  
140bb5309cf409 Xin Long 2020-09-29  911  	return 0;
140bb5309cf409 Xin Long 2020-09-29  912  }
140bb5309cf409 Xin Long 2020-09-29  913  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 31654 bytes --]

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

* Re: [PATCH net-next 00/15] sctp: Implement RFC6951: UDP Encapsulation of SCTP
  2020-09-29 13:48 [PATCH net-next 00/15] sctp: Implement RFC6951: UDP Encapsulation of SCTP Xin Long
  2020-09-29 13:48 ` Xin Long
  2020-09-29 13:48 ` [PATCH net-next 01/15] udp: check udp sock encap_type in __udp_lib_err Xin Long
@ 2020-09-29 16:39 ` Michael Tuexen
  2020-09-29 16:39   ` Michael Tuexen
  2020-09-29 17:49   ` Xin Long
  2020-10-01 12:41 ` Marcelo Ricardo Leitner
  3 siblings, 2 replies; 82+ messages in thread
From: Michael Tuexen @ 2020-09-29 16:39 UTC (permalink / raw)
  To: Xin Long
  Cc: network dev, linux-sctp, Marcelo Ricardo Leitner, Neil Horman,
	Tom Herbert, davem

[-- Attachment #1: Type: text/plain, Size: 5399 bytes --]

> On 29. Sep 2020, at 15:48, Xin Long <lucien.xin@gmail.com> wrote:
> 
> Description From the RFC:
> 
>   The Main Reasons:
> 
>   o  To allow SCTP traffic to pass through legacy NATs, which do not
>      provide native SCTP support as specified in [BEHAVE] and
>      [NATSUPP].
> 
>   o  To allow SCTP to be implemented on hosts that do not provide
>      direct access to the IP layer.  In particular, applications can
>      use their own SCTP implementation if the operating system does not
>      provide one.
> 
>   Implementation Notes:
> 
>   UDP-encapsulated SCTP is normally communicated between SCTP stacks
>   using the IANA-assigned UDP port number 9899 (sctp-tunneling) on both
>   ends.  There are circumstances where other ports may be used on
>   either end, and it might be required to use ports other than the
>   registered port.
> 
>   Each SCTP stack uses a single local UDP encapsulation port number as
>   the destination port for all its incoming SCTP packets, this greatly
>   simplifies implementation design.
> 
>   An SCTP implementation supporting UDP encapsulation MUST maintain a
>   remote UDP encapsulation port number per destination address for each
>   SCTP association.  Again, because the remote stack may be using ports
>   other than the well-known port, each port may be different from each
>   stack.  However, because of remapping of ports by NATs, the remote
>   ports associated with different remote IP addresses may not be
>   identical, even if they are associated with the same stack.
> 
>   Because the well-known port might not be used, implementations need
>   to allow other port numbers to be specified as a local or remote UDP
>   encapsulation port number through APIs.
Hi Xin Long,

I really appreciate that UDP encapsulation gets implemented in Linux.

The FreeBSD implementation initially had a bug due to missing text in
RFC6951. Please make sure the implementation also follows
https://www.ietf.org/id/draft-tuexen-tsvwg-sctp-udp-encaps-cons-03.html

The plan is to revise RFC6951 and let RFC6951bis include the contents of
the above Internet Draft. But this most likely will happen after the
NAT document is ready and RFC4960bis finished...

If you want to do some interop testing, a web server supporting SCTP/UDP
is running at interop.fh-muenster.de. You can find a client (phttpget) at
https://github.com/NEAT-project/HTTPOverSCTP.

Best regards
Michael

> 
> Patches:
> 
>   This patchset is using the udp4/6 tunnel APIs to implement the UDP
>   Encapsulation of SCTP with not much change in SCTP protocol stack
>   and with all current SCTP features keeped in Linux Kernel.
> 
>   1 - 4: Fix some UDP issues that may be triggered by SCTP over UDP.
>   5 - 7: Process incoming UDP encapsulated packets and ICMP packets.
>   8 -10: Remote encap port's update by sysctl, sockopt and packets.
>   11-14: Process outgoing pakects with UDP encapsulated and its GSO.
>      15: Enable this feature.
> 
> Tests:
> 
>  - lksctp-tools/src/func_tests with UDP Encapsulation enabled/disabled:
> 
>      Both make v4test and v6test passed.
> 
>  - sctp-tests with UDP Encapsulation enabled/disabled:
> 
>      repeatability/procdumps/sctpdiag/gsomtuchange/extoverflow/
>      sctphashtable passed. Others failed as expected due to those
>      "iptables -p sctp" rules.
> 
>  - netperf on lo/netns/virtio_net, with gso enabled/disabled and
>    with ip_checksum enabled/disabled, with UDP Encapsulation
>    enabled/disabled:
> 
>      No clear performance dropped.
> 
> Xin Long (15):
>  udp: check udp sock encap_type in __udp_lib_err
>  udp6: move the mss check after udp gso tunnel processing
>  udp: do checksum properly in skb_udp_tunnel_segment
>  udp: support sctp over udp in skb_udp_tunnel_segment
>  sctp: create udp4 sock and add its encap_rcv
>  sctp: create udp6 sock and set its encap_rcv
>  sctp: add encap_err_lookup for udp encap socks
>  sctp: add encap_port for netns sock asoc and transport
>  sctp: add SCTP_REMOTE_UDP_ENCAPS_PORT sockopt
>  sctp: allow changing transport encap_port by peer packets
>  sctp: add udphdr to overhead when udp_port is set
>  sctp: call sk_setup_caps in sctp_packet_transmit instead
>  sctp: support for sending packet over udp4 sock
>  sctp: support for sending packet over udp6 sock
>  sctp: enable udp tunneling socks
> 
> include/net/netns/sctp.h     |   8 +++
> include/net/sctp/constants.h |   2 +
> include/net/sctp/sctp.h      |   9 ++-
> include/net/sctp/sm.h        |   1 +
> include/net/sctp/structs.h   |  13 ++--
> include/uapi/linux/sctp.h    |   7 ++
> net/ipv4/udp.c               |   2 +-
> net/ipv4/udp_offload.c       |  16 +++--
> net/ipv6/udp.c               |   2 +-
> net/ipv6/udp_offload.c       | 154 +++++++++++++++++++++----------------------
> net/sctp/associola.c         |   4 ++
> net/sctp/ipv6.c              |  48 ++++++++++----
> net/sctp/output.c            |  22 +++----
> net/sctp/protocol.c          | 145 ++++++++++++++++++++++++++++++++++++----
> net/sctp/sm_make_chunk.c     |   1 +
> net/sctp/sm_statefuns.c      |   2 +
> net/sctp/socket.c            | 111 +++++++++++++++++++++++++++++++
> net/sctp/sysctl.c            |  53 +++++++++++++++
> 18 files changed, 471 insertions(+), 129 deletions(-)
> 
> -- 
> 2.1.0
> 


[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5257 bytes --]

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

* Re: [PATCH net-next 00/15] sctp: Implement RFC6951: UDP Encapsulation of SCTP
  2020-09-29 16:39 ` [PATCH net-next 00/15] sctp: Implement RFC6951: UDP Encapsulation of SCTP Michael Tuexen
@ 2020-09-29 16:39   ` Michael Tuexen
  2020-09-29 17:49   ` Xin Long
  1 sibling, 0 replies; 82+ messages in thread
From: Michael Tuexen @ 2020-09-29 16:39 UTC (permalink / raw)
  To: Xin Long
  Cc: network dev, linux-sctp, Marcelo Ricardo Leitner, Neil Horman,
	Tom Herbert, davem

[-- Attachment #1: Type: text/plain, Size: 5399 bytes --]

> On 29. Sep 2020, at 15:48, Xin Long <lucien.xin@gmail.com> wrote:
> 
> Description From the RFC:
> 
>   The Main Reasons:
> 
>   o  To allow SCTP traffic to pass through legacy NATs, which do not
>      provide native SCTP support as specified in [BEHAVE] and
>      [NATSUPP].
> 
>   o  To allow SCTP to be implemented on hosts that do not provide
>      direct access to the IP layer.  In particular, applications can
>      use their own SCTP implementation if the operating system does not
>      provide one.
> 
>   Implementation Notes:
> 
>   UDP-encapsulated SCTP is normally communicated between SCTP stacks
>   using the IANA-assigned UDP port number 9899 (sctp-tunneling) on both
>   ends.  There are circumstances where other ports may be used on
>   either end, and it might be required to use ports other than the
>   registered port.
> 
>   Each SCTP stack uses a single local UDP encapsulation port number as
>   the destination port for all its incoming SCTP packets, this greatly
>   simplifies implementation design.
> 
>   An SCTP implementation supporting UDP encapsulation MUST maintain a
>   remote UDP encapsulation port number per destination address for each
>   SCTP association.  Again, because the remote stack may be using ports
>   other than the well-known port, each port may be different from each
>   stack.  However, because of remapping of ports by NATs, the remote
>   ports associated with different remote IP addresses may not be
>   identical, even if they are associated with the same stack.
> 
>   Because the well-known port might not be used, implementations need
>   to allow other port numbers to be specified as a local or remote UDP
>   encapsulation port number through APIs.
Hi Xin Long,

I really appreciate that UDP encapsulation gets implemented in Linux.

The FreeBSD implementation initially had a bug due to missing text in
RFC6951. Please make sure the implementation also follows
https://www.ietf.org/id/draft-tuexen-tsvwg-sctp-udp-encaps-cons-03.html

The plan is to revise RFC6951 and let RFC6951bis include the contents of
the above Internet Draft. But this most likely will happen after the
NAT document is ready and RFC4960bis finished...

If you want to do some interop testing, a web server supporting SCTP/UDP
is running at interop.fh-muenster.de. You can find a client (phttpget) at
https://github.com/NEAT-project/HTTPOverSCTP.

Best regards
Michael

> 
> Patches:
> 
>   This patchset is using the udp4/6 tunnel APIs to implement the UDP
>   Encapsulation of SCTP with not much change in SCTP protocol stack
>   and with all current SCTP features keeped in Linux Kernel.
> 
>   1 - 4: Fix some UDP issues that may be triggered by SCTP over UDP.
>   5 - 7: Process incoming UDP encapsulated packets and ICMP packets.
>   8 -10: Remote encap port's update by sysctl, sockopt and packets.
>   11-14: Process outgoing pakects with UDP encapsulated and its GSO.
>      15: Enable this feature.
> 
> Tests:
> 
>  - lksctp-tools/src/func_tests with UDP Encapsulation enabled/disabled:
> 
>      Both make v4test and v6test passed.
> 
>  - sctp-tests with UDP Encapsulation enabled/disabled:
> 
>      repeatability/procdumps/sctpdiag/gsomtuchange/extoverflow/
>      sctphashtable passed. Others failed as expected due to those
>      "iptables -p sctp" rules.
> 
>  - netperf on lo/netns/virtio_net, with gso enabled/disabled and
>    with ip_checksum enabled/disabled, with UDP Encapsulation
>    enabled/disabled:
> 
>      No clear performance dropped.
> 
> Xin Long (15):
>  udp: check udp sock encap_type in __udp_lib_err
>  udp6: move the mss check after udp gso tunnel processing
>  udp: do checksum properly in skb_udp_tunnel_segment
>  udp: support sctp over udp in skb_udp_tunnel_segment
>  sctp: create udp4 sock and add its encap_rcv
>  sctp: create udp6 sock and set its encap_rcv
>  sctp: add encap_err_lookup for udp encap socks
>  sctp: add encap_port for netns sock asoc and transport
>  sctp: add SCTP_REMOTE_UDP_ENCAPS_PORT sockopt
>  sctp: allow changing transport encap_port by peer packets
>  sctp: add udphdr to overhead when udp_port is set
>  sctp: call sk_setup_caps in sctp_packet_transmit instead
>  sctp: support for sending packet over udp4 sock
>  sctp: support for sending packet over udp6 sock
>  sctp: enable udp tunneling socks
> 
> include/net/netns/sctp.h     |   8 +++
> include/net/sctp/constants.h |   2 +
> include/net/sctp/sctp.h      |   9 ++-
> include/net/sctp/sm.h        |   1 +
> include/net/sctp/structs.h   |  13 ++--
> include/uapi/linux/sctp.h    |   7 ++
> net/ipv4/udp.c               |   2 +-
> net/ipv4/udp_offload.c       |  16 +++--
> net/ipv6/udp.c               |   2 +-
> net/ipv6/udp_offload.c       | 154 +++++++++++++++++++++----------------------
> net/sctp/associola.c         |   4 ++
> net/sctp/ipv6.c              |  48 ++++++++++----
> net/sctp/output.c            |  22 +++----
> net/sctp/protocol.c          | 145 ++++++++++++++++++++++++++++++++++++----
> net/sctp/sm_make_chunk.c     |   1 +
> net/sctp/sm_statefuns.c      |   2 +
> net/sctp/socket.c            | 111 +++++++++++++++++++++++++++++++
> net/sctp/sysctl.c            |  53 +++++++++++++++
> 18 files changed, 471 insertions(+), 129 deletions(-)
> 
> -- 
> 2.1.0
> 


[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5257 bytes --]

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

* Re: [PATCH net-next 00/15] sctp: Implement RFC6951: UDP Encapsulation of SCTP
  2020-09-29 16:39 ` [PATCH net-next 00/15] sctp: Implement RFC6951: UDP Encapsulation of SCTP Michael Tuexen
  2020-09-29 16:39   ` Michael Tuexen
@ 2020-09-29 17:49   ` Xin Long
  2020-09-29 18:04     ` Xin Long
  1 sibling, 1 reply; 82+ messages in thread
From: Xin Long @ 2020-09-29 17:49 UTC (permalink / raw)
  To: Michael Tuexen
  Cc: network dev, linux-sctp, Marcelo Ricardo Leitner, Neil Horman,
	Tom Herbert, davem

On Wed, Sep 30, 2020 at 12:40 AM Michael Tuexen <tuexen@fh-muenster.de> wrote:
>
> > On 29. Sep 2020, at 15:48, Xin Long <lucien.xin@gmail.com> wrote:
> >
> > Description From the RFC:
> >
> >   The Main Reasons:
> >
> >   o  To allow SCTP traffic to pass through legacy NATs, which do not
> >      provide native SCTP support as specified in [BEHAVE] and
> >      [NATSUPP].
> >
> >   o  To allow SCTP to be implemented on hosts that do not provide
> >      direct access to the IP layer.  In particular, applications can
> >      use their own SCTP implementation if the operating system does not
> >      provide one.
> >
> >   Implementation Notes:
> >
> >   UDP-encapsulated SCTP is normally communicated between SCTP stacks
> >   using the IANA-assigned UDP port number 9899 (sctp-tunneling) on both
> >   ends.  There are circumstances where other ports may be used on
> >   either end, and it might be required to use ports other than the
> >   registered port.
> >
> >   Each SCTP stack uses a single local UDP encapsulation port number as
> >   the destination port for all its incoming SCTP packets, this greatly
> >   simplifies implementation design.
> >
> >   An SCTP implementation supporting UDP encapsulation MUST maintain a
> >   remote UDP encapsulation port number per destination address for each
> >   SCTP association.  Again, because the remote stack may be using ports
> >   other than the well-known port, each port may be different from each
> >   stack.  However, because of remapping of ports by NATs, the remote
> >   ports associated with different remote IP addresses may not be
> >   identical, even if they are associated with the same stack.
> >
> >   Because the well-known port might not be used, implementations need
> >   to allow other port numbers to be specified as a local or remote UDP
> >   encapsulation port number through APIs.
> Hi Xin Long,
>
> I really appreciate that UDP encapsulation gets implemented in Linux.
>
> The FreeBSD implementation initially had a bug due to missing text in
> RFC6951. Please make sure the implementation also follows
> https://www.ietf.org/id/draft-tuexen-tsvwg-sctp-udp-encaps-cons-03.html
Hi, Michael

Thanks for sharing this doc.

3. Handling of Out of the Blue Packets:
This patchset can handle it well.

4. Handling of SCTP Packets Containing an INIT Chunk Matching an
Existing Associations:
These cases responding with ABORT, I will need to add.

>
> The plan is to revise RFC6951 and let RFC6951bis include the contents of
> the above Internet Draft. But this most likely will happen after the
> NAT document is ready and RFC4960bis finished...
understand.

>
> If you want to do some interop testing, a web server supporting SCTP/UDP
> is running at interop.fh-muenster.de. You can find a client (phttpget) at
> https://github.com/NEAT-project/HTTPOverSCTP.
got it.

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

* Re: [PATCH net-next 00/15] sctp: Implement RFC6951: UDP Encapsulation of SCTP
  2020-09-29 17:49   ` Xin Long
@ 2020-09-29 18:04     ` Xin Long
  0 siblings, 0 replies; 82+ messages in thread
From: Xin Long @ 2020-09-29 18:04 UTC (permalink / raw)
  To: Michael Tuexen
  Cc: network dev, linux-sctp, Marcelo Ricardo Leitner, Neil Horman,
	Tom Herbert, davem

On Wed, Sep 30, 2020 at 12:40 AM Michael Tuexen <tuexen@fh-muenster.de> wrote:
>
> > On 29. Sep 2020, at 15:48, Xin Long <lucien.xin@gmail.com> wrote:
> >
> > Description From the RFC:
> >
> >   The Main Reasons:
> >
> >   o  To allow SCTP traffic to pass through legacy NATs, which do not
> >      provide native SCTP support as specified in [BEHAVE] and
> >      [NATSUPP].
> >
> >   o  To allow SCTP to be implemented on hosts that do not provide
> >      direct access to the IP layer.  In particular, applications can
> >      use their own SCTP implementation if the operating system does not
> >      provide one.
> >
> >   Implementation Notes:
> >
> >   UDP-encapsulated SCTP is normally communicated between SCTP stacks
> >   using the IANA-assigned UDP port number 9899 (sctp-tunneling) on both
> >   ends.  There are circumstances where other ports may be used on
> >   either end, and it might be required to use ports other than the
> >   registered port.
> >
> >   Each SCTP stack uses a single local UDP encapsulation port number as
> >   the destination port for all its incoming SCTP packets, this greatly
> >   simplifies implementation design.
> >
> >   An SCTP implementation supporting UDP encapsulation MUST maintain a
> >   remote UDP encapsulation port number per destination address for each
> >   SCTP association.  Again, because the remote stack may be using ports
> >   other than the well-known port, each port may be different from each
> >   stack.  However, because of remapping of ports by NATs, the remote
> >   ports associated with different remote IP addresses may not be
> >   identical, even if they are associated with the same stack.
> >
> >   Because the well-known port might not be used, implementations need
> >   to allow other port numbers to be specified as a local or remote UDP
> >   encapsulation port number through APIs.
> Hi Xin Long,
>
> I really appreciate that UDP encapsulation gets implemented in Linux.
>
> The FreeBSD implementation initially had a bug due to missing text in
> RFC6951. Please make sure the implementation also follows
> https://www.ietf.org/id/draft-tuexen-tsvwg-sctp-udp-encaps-cons-03.html
Hi, Michael

Thanks for sharing this doc.

3. Handling of Out of the Blue Packets:
This patchset can handle it well.

4. Handling of SCTP Packets Containing an INIT Chunk Matching an
Existing Associations:
These cases responding with ABORT, I will need to add.

>
> The plan is to revise RFC6951 and let RFC6951bis include the contents of
> the above Internet Draft. But this most likely will happen after the
> NAT document is ready and RFC4960bis finished...
understand.

>
> If you want to do some interop testing, a web server supporting SCTP/UDP
> is running at interop.fh-muenster.de. You can find a client (phttpget) at
> https://github.com/NEAT-project/HTTPOverSCTP.
got it.

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

* Re: [PATCH net-next 11/15] sctp: add udphdr to overhead when udp_port is set
  2020-09-29 13:49                     ` [PATCH net-next 11/15] sctp: add udphdr to overhead when udp_port is set Xin Long
  2020-09-29 13:49                       ` Xin Long
  2020-09-29 13:49                       ` [PATCH net-next 12/15] sctp: call sk_setup_caps in sctp_packet_transmit instead Xin Long
@ 2020-09-29 19:00                       ` kernel test robot
  2020-09-29 19:00                         ` kernel test robot
  2020-10-03  4:08                         ` Marcelo Ricardo Leitner
  2020-10-03  4:07                       ` Marcelo Ricardo Leitner
  3 siblings, 2 replies; 82+ messages in thread
From: kernel test robot @ 2020-09-29 19:00 UTC (permalink / raw)
  To: Xin Long, network dev, linux-sctp
  Cc: kbuild-all, Marcelo Ricardo Leitner, Neil Horman, Michael Tuexen,
	Tom Herbert, davem

[-- Attachment #1: Type: text/plain, Size: 2506 bytes --]

Hi Xin,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on net-next/master]

url:    https://github.com/0day-ci/linux/commits/Xin-Long/sctp-Implement-RFC6951-UDP-Encapsulation-of-SCTP/20200929-215159
base:   https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git 280095713ce244e8dbdfb059cdca695baa72230a
config: c6x-randconfig-r023-20200929 (attached as .config)
compiler: c6x-elf-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/38f71b63a83947b86b356d8af1ba077027d27deb
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Xin-Long/sctp-Implement-RFC6951-UDP-Encapsulation-of-SCTP/20200929-215159
        git checkout 38f71b63a83947b86b356d8af1ba077027d27deb
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=c6x 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   In file included from include/net/sctp/checksum.h:27,
                    from net/netfilter/nf_nat_proto.c:16:
   include/net/sctp/sctp.h: In function 'sctp_mtu_payload':
>> include/net/sctp/sctp.h:583:31: error: 'struct net' has no member named 'sctp'; did you mean 'ct'?
     583 |   if (sock_net(&sp->inet.sk)->sctp.udp_port)
         |                               ^~~~
         |                               ct

vim +583 include/net/sctp/sctp.h

   572	
   573	/* Calculate max payload size given a MTU, or the total overhead if
   574	 * given MTU is zero
   575	 */
   576	static inline __u32 sctp_mtu_payload(const struct sctp_sock *sp,
   577					     __u32 mtu, __u32 extra)
   578	{
   579		__u32 overhead = sizeof(struct sctphdr) + extra;
   580	
   581		if (sp) {
   582			overhead += sp->pf->af->net_header_len;
 > 583			if (sock_net(&sp->inet.sk)->sctp.udp_port)
   584				overhead += sizeof(struct udphdr);
   585		} else {
   586			overhead += sizeof(struct ipv6hdr);
   587		}
   588	
   589		if (WARN_ON_ONCE(mtu && mtu <= overhead))
   590			mtu = overhead;
   591	
   592		return mtu ? mtu - overhead : overhead;
   593	}
   594	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 27152 bytes --]

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

* Re: [PATCH net-next 11/15] sctp: add udphdr to overhead when udp_port is set
  2020-09-29 19:00                       ` [PATCH net-next 11/15] sctp: add udphdr to overhead when udp_port is set kernel test robot
@ 2020-09-29 19:00                         ` kernel test robot
  2020-10-03  4:08                         ` Marcelo Ricardo Leitner
  1 sibling, 0 replies; 82+ messages in thread
From: kernel test robot @ 2020-09-29 19:00 UTC (permalink / raw)
  To: Xin Long, network dev, linux-sctp
  Cc: kbuild-all, Marcelo Ricardo Leitner, Neil Horman, Michael Tuexen,
	Tom Herbert, davem

[-- Attachment #1: Type: text/plain, Size: 2506 bytes --]

Hi Xin,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on net-next/master]

url:    https://github.com/0day-ci/linux/commits/Xin-Long/sctp-Implement-RFC6951-UDP-Encapsulation-of-SCTP/20200929-215159
base:   https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git 280095713ce244e8dbdfb059cdca695baa72230a
config: c6x-randconfig-r023-20200929 (attached as .config)
compiler: c6x-elf-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/38f71b63a83947b86b356d8af1ba077027d27deb
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Xin-Long/sctp-Implement-RFC6951-UDP-Encapsulation-of-SCTP/20200929-215159
        git checkout 38f71b63a83947b86b356d8af1ba077027d27deb
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=c6x 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   In file included from include/net/sctp/checksum.h:27,
                    from net/netfilter/nf_nat_proto.c:16:
   include/net/sctp/sctp.h: In function 'sctp_mtu_payload':
>> include/net/sctp/sctp.h:583:31: error: 'struct net' has no member named 'sctp'; did you mean 'ct'?
     583 |   if (sock_net(&sp->inet.sk)->sctp.udp_port)
         |                               ^~~~
         |                               ct

vim +583 include/net/sctp/sctp.h

   572	
   573	/* Calculate max payload size given a MTU, or the total overhead if
   574	 * given MTU is zero
   575	 */
   576	static inline __u32 sctp_mtu_payload(const struct sctp_sock *sp,
   577					     __u32 mtu, __u32 extra)
   578	{
   579		__u32 overhead = sizeof(struct sctphdr) + extra;
   580	
   581		if (sp) {
   582			overhead += sp->pf->af->net_header_len;
 > 583			if (sock_net(&sp->inet.sk)->sctp.udp_port)
   584				overhead += sizeof(struct udphdr);
   585		} else {
   586			overhead += sizeof(struct ipv6hdr);
   587		}
   588	
   589		if (WARN_ON_ONCE(mtu && mtu <= overhead))
   590			mtu = overhead;
   591	
   592		return mtu ? mtu - overhead : overhead;
   593	}
   594	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 27152 bytes --]

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

* Re: [PATCH net-next 13/15] sctp: support for sending packet over udp4 sock
  2020-09-29 13:49                         ` [PATCH net-next 13/15] sctp: support for sending packet over udp4 sock Xin Long
                                             ` (2 preceding siblings ...)
  2020-09-29 16:25                           ` [PATCH net-next 13/15] sctp: support for sending packet over udp4 sock kernel test robot
@ 2020-09-29 19:19                           ` kernel test robot
  2020-09-29 19:19                             ` kernel test robot
  3 siblings, 1 reply; 82+ messages in thread
From: kernel test robot @ 2020-09-29 19:19 UTC (permalink / raw)
  To: Xin Long, network dev, linux-sctp
  Cc: kbuild-all, Marcelo Ricardo Leitner, Neil Horman, Michael Tuexen,
	Tom Herbert, davem

[-- Attachment #1: Type: text/plain, Size: 5170 bytes --]

Hi Xin,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on net-next/master]

url:    https://github.com/0day-ci/linux/commits/Xin-Long/sctp-Implement-RFC6951-UDP-Encapsulation-of-SCTP/20200929-215159
base:   https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git 280095713ce244e8dbdfb059cdca695baa72230a
config: x86_64-randconfig-a002-20200929 (attached as .config)
compiler: clang version 12.0.0 (https://github.com/llvm/llvm-project de55ebe3bbc77882901ae2b9654503b7611b28f3)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # install x86_64 cross compiling tool for clang build
        # apt-get install binutils-x86-64-linux-gnu
        # https://github.com/0day-ci/linux/commit/a1016fd4a55f176fcc2eae05052a61ad7d5a142b
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Xin-Long/sctp-Implement-RFC6951-UDP-Encapsulation-of-SCTP/20200929-215159
        git checkout a1016fd4a55f176fcc2eae05052a61ad7d5a142b
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

>> net/sctp/protocol.c:894:11: error: no member named 'local_ip6' in 'struct udp_port_cfg'; did you mean 'local_ip'?
           udp_conf.local_ip6 = in6addr_any;
                    ^~~~~~~~~
                    local_ip
   include/net/udp_tunnel.h:18:19: note: 'local_ip' declared here
                   struct in_addr          local_ip;
                                           ^
>> net/sctp/protocol.c:894:21: error: assigning to 'struct in_addr' from incompatible type 'const struct in6_addr'
           udp_conf.local_ip6 = in6addr_any;
                              ^ ~~~~~~~~~~~
   2 errors generated.

vim +894 net/sctp/protocol.c

a330bee1c278f86 Xin Long 2020-09-29  870  
140bb5309cf4095 Xin Long 2020-09-29  871  int sctp_udp_sock_start(struct net *net)
140bb5309cf4095 Xin Long 2020-09-29  872  {
140bb5309cf4095 Xin Long 2020-09-29  873  	struct udp_tunnel_sock_cfg tuncfg = {NULL};
140bb5309cf4095 Xin Long 2020-09-29  874  	struct udp_port_cfg udp_conf = {0};
140bb5309cf4095 Xin Long 2020-09-29  875  	struct socket *sock;
140bb5309cf4095 Xin Long 2020-09-29  876  	int err;
140bb5309cf4095 Xin Long 2020-09-29  877  
140bb5309cf4095 Xin Long 2020-09-29  878  	udp_conf.family = AF_INET;
140bb5309cf4095 Xin Long 2020-09-29  879  	udp_conf.local_ip.s_addr = htonl(INADDR_ANY);
140bb5309cf4095 Xin Long 2020-09-29  880  	udp_conf.local_udp_port = htons(net->sctp.udp_port);
140bb5309cf4095 Xin Long 2020-09-29  881  	err = udp_sock_create(net, &udp_conf, &sock);
140bb5309cf4095 Xin Long 2020-09-29  882  	if (err)
140bb5309cf4095 Xin Long 2020-09-29  883  		return err;
140bb5309cf4095 Xin Long 2020-09-29  884  
140bb5309cf4095 Xin Long 2020-09-29  885  	tuncfg.encap_type = 1;
140bb5309cf4095 Xin Long 2020-09-29  886  	tuncfg.encap_rcv = sctp_udp_rcv;
a330bee1c278f86 Xin Long 2020-09-29  887  	tuncfg.encap_err_lookup = sctp_udp_err_lookup;
140bb5309cf4095 Xin Long 2020-09-29  888  	setup_udp_tunnel_sock(net, sock, &tuncfg);
140bb5309cf4095 Xin Long 2020-09-29  889  	net->sctp.udp4_sock = sock->sk;
140bb5309cf4095 Xin Long 2020-09-29  890  
cff8956126170d6 Xin Long 2020-09-29  891  	memset(&udp_conf, 0, sizeof(udp_conf));
cff8956126170d6 Xin Long 2020-09-29  892  
cff8956126170d6 Xin Long 2020-09-29  893  	udp_conf.family = AF_INET6;
cff8956126170d6 Xin Long 2020-09-29 @894  	udp_conf.local_ip6 = in6addr_any;
cff8956126170d6 Xin Long 2020-09-29  895  	udp_conf.local_udp_port = htons(net->sctp.udp_port);
cff8956126170d6 Xin Long 2020-09-29  896  	udp_conf.use_udp6_rx_checksums = true;
cff8956126170d6 Xin Long 2020-09-29  897  	udp_conf.ipv6_v6only = true;
cff8956126170d6 Xin Long 2020-09-29  898  	err = udp_sock_create(net, &udp_conf, &sock);
cff8956126170d6 Xin Long 2020-09-29  899  	if (err) {
cff8956126170d6 Xin Long 2020-09-29  900  		udp_tunnel_sock_release(net->sctp.udp4_sock->sk_socket);
cff8956126170d6 Xin Long 2020-09-29  901  		net->sctp.udp4_sock = NULL;
cff8956126170d6 Xin Long 2020-09-29  902  		return err;
cff8956126170d6 Xin Long 2020-09-29  903  	}
cff8956126170d6 Xin Long 2020-09-29  904  
cff8956126170d6 Xin Long 2020-09-29  905  	tuncfg.encap_type = 1;
cff8956126170d6 Xin Long 2020-09-29  906  	tuncfg.encap_rcv = sctp_udp_rcv;
a330bee1c278f86 Xin Long 2020-09-29  907  	tuncfg.encap_err_lookup = sctp_udp_err_lookup;
cff8956126170d6 Xin Long 2020-09-29  908  	setup_udp_tunnel_sock(net, sock, &tuncfg);
cff8956126170d6 Xin Long 2020-09-29  909  	net->sctp.udp6_sock = sock->sk;
cff8956126170d6 Xin Long 2020-09-29  910  
140bb5309cf4095 Xin Long 2020-09-29  911  	return 0;
140bb5309cf4095 Xin Long 2020-09-29  912  }
140bb5309cf4095 Xin Long 2020-09-29  913  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 30443 bytes --]

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

* Re: [PATCH net-next 13/15] sctp: support for sending packet over udp4 sock
  2020-09-29 19:19                           ` kernel test robot
@ 2020-09-29 19:19                             ` kernel test robot
  0 siblings, 0 replies; 82+ messages in thread
From: kernel test robot @ 2020-09-29 19:19 UTC (permalink / raw)
  To: Xin Long, network dev, linux-sctp
  Cc: kbuild-all, Marcelo Ricardo Leitner, Neil Horman, Michael Tuexen,
	Tom Herbert, davem

[-- Attachment #1: Type: text/plain, Size: 5170 bytes --]

Hi Xin,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on net-next/master]

url:    https://github.com/0day-ci/linux/commits/Xin-Long/sctp-Implement-RFC6951-UDP-Encapsulation-of-SCTP/20200929-215159
base:   https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git 280095713ce244e8dbdfb059cdca695baa72230a
config: x86_64-randconfig-a002-20200929 (attached as .config)
compiler: clang version 12.0.0 (https://github.com/llvm/llvm-project de55ebe3bbc77882901ae2b9654503b7611b28f3)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # install x86_64 cross compiling tool for clang build
        # apt-get install binutils-x86-64-linux-gnu
        # https://github.com/0day-ci/linux/commit/a1016fd4a55f176fcc2eae05052a61ad7d5a142b
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Xin-Long/sctp-Implement-RFC6951-UDP-Encapsulation-of-SCTP/20200929-215159
        git checkout a1016fd4a55f176fcc2eae05052a61ad7d5a142b
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

>> net/sctp/protocol.c:894:11: error: no member named 'local_ip6' in 'struct udp_port_cfg'; did you mean 'local_ip'?
           udp_conf.local_ip6 = in6addr_any;
                    ^~~~~~~~~
                    local_ip
   include/net/udp_tunnel.h:18:19: note: 'local_ip' declared here
                   struct in_addr          local_ip;
                                           ^
>> net/sctp/protocol.c:894:21: error: assigning to 'struct in_addr' from incompatible type 'const struct in6_addr'
           udp_conf.local_ip6 = in6addr_any;
                              ^ ~~~~~~~~~~~
   2 errors generated.

vim +894 net/sctp/protocol.c

a330bee1c278f86 Xin Long 2020-09-29  870  
140bb5309cf4095 Xin Long 2020-09-29  871  int sctp_udp_sock_start(struct net *net)
140bb5309cf4095 Xin Long 2020-09-29  872  {
140bb5309cf4095 Xin Long 2020-09-29  873  	struct udp_tunnel_sock_cfg tuncfg = {NULL};
140bb5309cf4095 Xin Long 2020-09-29  874  	struct udp_port_cfg udp_conf = {0};
140bb5309cf4095 Xin Long 2020-09-29  875  	struct socket *sock;
140bb5309cf4095 Xin Long 2020-09-29  876  	int err;
140bb5309cf4095 Xin Long 2020-09-29  877  
140bb5309cf4095 Xin Long 2020-09-29  878  	udp_conf.family = AF_INET;
140bb5309cf4095 Xin Long 2020-09-29  879  	udp_conf.local_ip.s_addr = htonl(INADDR_ANY);
140bb5309cf4095 Xin Long 2020-09-29  880  	udp_conf.local_udp_port = htons(net->sctp.udp_port);
140bb5309cf4095 Xin Long 2020-09-29  881  	err = udp_sock_create(net, &udp_conf, &sock);
140bb5309cf4095 Xin Long 2020-09-29  882  	if (err)
140bb5309cf4095 Xin Long 2020-09-29  883  		return err;
140bb5309cf4095 Xin Long 2020-09-29  884  
140bb5309cf4095 Xin Long 2020-09-29  885  	tuncfg.encap_type = 1;
140bb5309cf4095 Xin Long 2020-09-29  886  	tuncfg.encap_rcv = sctp_udp_rcv;
a330bee1c278f86 Xin Long 2020-09-29  887  	tuncfg.encap_err_lookup = sctp_udp_err_lookup;
140bb5309cf4095 Xin Long 2020-09-29  888  	setup_udp_tunnel_sock(net, sock, &tuncfg);
140bb5309cf4095 Xin Long 2020-09-29  889  	net->sctp.udp4_sock = sock->sk;
140bb5309cf4095 Xin Long 2020-09-29  890  
cff8956126170d6 Xin Long 2020-09-29  891  	memset(&udp_conf, 0, sizeof(udp_conf));
cff8956126170d6 Xin Long 2020-09-29  892  
cff8956126170d6 Xin Long 2020-09-29  893  	udp_conf.family = AF_INET6;
cff8956126170d6 Xin Long 2020-09-29 @894  	udp_conf.local_ip6 = in6addr_any;
cff8956126170d6 Xin Long 2020-09-29  895  	udp_conf.local_udp_port = htons(net->sctp.udp_port);
cff8956126170d6 Xin Long 2020-09-29  896  	udp_conf.use_udp6_rx_checksums = true;
cff8956126170d6 Xin Long 2020-09-29  897  	udp_conf.ipv6_v6only = true;
cff8956126170d6 Xin Long 2020-09-29  898  	err = udp_sock_create(net, &udp_conf, &sock);
cff8956126170d6 Xin Long 2020-09-29  899  	if (err) {
cff8956126170d6 Xin Long 2020-09-29  900  		udp_tunnel_sock_release(net->sctp.udp4_sock->sk_socket);
cff8956126170d6 Xin Long 2020-09-29  901  		net->sctp.udp4_sock = NULL;
cff8956126170d6 Xin Long 2020-09-29  902  		return err;
cff8956126170d6 Xin Long 2020-09-29  903  	}
cff8956126170d6 Xin Long 2020-09-29  904  
cff8956126170d6 Xin Long 2020-09-29  905  	tuncfg.encap_type = 1;
cff8956126170d6 Xin Long 2020-09-29  906  	tuncfg.encap_rcv = sctp_udp_rcv;
a330bee1c278f86 Xin Long 2020-09-29  907  	tuncfg.encap_err_lookup = sctp_udp_err_lookup;
cff8956126170d6 Xin Long 2020-09-29  908  	setup_udp_tunnel_sock(net, sock, &tuncfg);
cff8956126170d6 Xin Long 2020-09-29  909  	net->sctp.udp6_sock = sock->sk;
cff8956126170d6 Xin Long 2020-09-29  910  
140bb5309cf4095 Xin Long 2020-09-29  911  	return 0;
140bb5309cf4095 Xin Long 2020-09-29  912  }
140bb5309cf4095 Xin Long 2020-09-29  913  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 30443 bytes --]

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

* Re: [PATCH net-next 13/15] sctp: support for sending packet over udp4 sock
  2020-09-29 16:25                           ` [PATCH net-next 13/15] sctp: support for sending packet over udp4 sock kernel test robot
  2020-09-29 16:25                             ` kernel test robot
@ 2020-09-30  6:26                             ` Xin Long
  2020-09-30  6:26                               ` Xin Long
  1 sibling, 1 reply; 82+ messages in thread
From: Xin Long @ 2020-09-30  6:26 UTC (permalink / raw)
  To: kernel test robot
  Cc: network dev, linux-sctp, kbuild-all, Marcelo Ricardo Leitner,
	Neil Horman, Michael Tuexen, Tom Herbert, davem

On Wed, Sep 30, 2020 at 12:26 AM kernel test robot <lkp@intel.com> wrote:
>
> Hi Xin,
>
> Thank you for the patch! Yet something to improve:
>
> [auto build test ERROR on net-next/master]
>
> url:    https://github.com/0day-ci/linux/commits/Xin-Long/sctp-Implement-RFC6951-UDP-Encapsulation-of-SCTP/20200929-215159
> base:   https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git 280095713ce244e8dbdfb059cdca695baa72230a
> config: ia64-randconfig-r014-20200929 (attached as .config)
> compiler: ia64-linux-gcc (GCC) 9.3.0
> reproduce (this is a W=1 build):
>         wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
>         chmod +x ~/bin/make.cross
>         # https://github.com/0day-ci/linux/commit/a1016fd4a55f176fcc2eae05052a61ad7d5a142b
>         git remote add linux-review https://github.com/0day-ci/linux
>         git fetch --no-tags linux-review Xin-Long/sctp-Implement-RFC6951-UDP-Encapsulation-of-SCTP/20200929-215159
>         git checkout a1016fd4a55f176fcc2eae05052a61ad7d5a142b
>         # save the attached .config to linux build tree
>         COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=ia64
>
> If you fix the issue, kindly add following tag as appropriate
> Reported-by: kernel test robot <lkp@intel.com>
>
> All errors (new ones prefixed by >>):
>
>    net/sctp/protocol.c: In function 'sctp_udp_sock_start':
> >> net/sctp/protocol.c:894:11: error: 'struct udp_port_cfg' has no member named 'local_ip6'; did you mean 'local_ip'?
>      894 |  udp_conf.local_ip6 = in6addr_any;
>          |           ^~~~~~~~~
>          |           local_ip
>
> vim +894 net/sctp/protocol.c
>
> a330bee1c278f8 Xin Long 2020-09-29  870
> 140bb5309cf409 Xin Long 2020-09-29  871  int sctp_udp_sock_start(struct net *net)
> 140bb5309cf409 Xin Long 2020-09-29  872  {
> 140bb5309cf409 Xin Long 2020-09-29  873         struct udp_tunnel_sock_cfg tuncfg = {NULL};
> 140bb5309cf409 Xin Long 2020-09-29  874         struct udp_port_cfg udp_conf = {0};
> 140bb5309cf409 Xin Long 2020-09-29  875         struct socket *sock;
> 140bb5309cf409 Xin Long 2020-09-29  876         int err;
> 140bb5309cf409 Xin Long 2020-09-29  877
> 140bb5309cf409 Xin Long 2020-09-29  878         udp_conf.family = AF_INET;
> 140bb5309cf409 Xin Long 2020-09-29  879         udp_conf.local_ip.s_addr = htonl(INADDR_ANY);
> 140bb5309cf409 Xin Long 2020-09-29  880         udp_conf.local_udp_port = htons(net->sctp.udp_port);
> 140bb5309cf409 Xin Long 2020-09-29  881         err = udp_sock_create(net, &udp_conf, &sock);
> 140bb5309cf409 Xin Long 2020-09-29  882         if (err)
> 140bb5309cf409 Xin Long 2020-09-29  883                 return err;
> 140bb5309cf409 Xin Long 2020-09-29  884
> 140bb5309cf409 Xin Long 2020-09-29  885         tuncfg.encap_type = 1;
> 140bb5309cf409 Xin Long 2020-09-29  886         tuncfg.encap_rcv = sctp_udp_rcv;
> a330bee1c278f8 Xin Long 2020-09-29  887         tuncfg.encap_err_lookup = sctp_udp_err_lookup;
> 140bb5309cf409 Xin Long 2020-09-29  888         setup_udp_tunnel_sock(net, sock, &tuncfg);
> 140bb5309cf409 Xin Long 2020-09-29  889         net->sctp.udp4_sock = sock->sk;
> 140bb5309cf409 Xin Long 2020-09-29  890
> cff8956126170d Xin Long 2020-09-29  891         memset(&udp_conf, 0, sizeof(udp_conf));
> cff8956126170d Xin Long 2020-09-29  892
> cff8956126170d Xin Long 2020-09-29  893         udp_conf.family = AF_INET6;
> cff8956126170d Xin Long 2020-09-29 @894         udp_conf.local_ip6 = in6addr_any;
> cff8956126170d Xin Long 2020-09-29  895         udp_conf.local_udp_port = htons(net->sctp.udp_port);
> cff8956126170d Xin Long 2020-09-29  896         udp_conf.use_udp6_rx_checksums = true;
> cff8956126170d Xin Long 2020-09-29  897         udp_conf.ipv6_v6only = true;
> cff8956126170d Xin Long 2020-09-29  898         err = udp_sock_create(net, &udp_conf, &sock);
> cff8956126170d Xin Long 2020-09-29  899         if (err) {
> cff8956126170d Xin Long 2020-09-29  900                 udp_tunnel_sock_release(net->sctp.udp4_sock->sk_socket);
> cff8956126170d Xin Long 2020-09-29  901                 net->sctp.udp4_sock = NULL;
> cff8956126170d Xin Long 2020-09-29  902                 return err;
> cff8956126170d Xin Long 2020-09-29  903         }
> cff8956126170d Xin Long 2020-09-29  904
> cff8956126170d Xin Long 2020-09-29  905         tuncfg.encap_type = 1;
> cff8956126170d Xin Long 2020-09-29  906         tuncfg.encap_rcv = sctp_udp_rcv;
> a330bee1c278f8 Xin Long 2020-09-29  907         tuncfg.encap_err_lookup = sctp_udp_err_lookup;
> cff8956126170d Xin Long 2020-09-29  908         setup_udp_tunnel_sock(net, sock, &tuncfg);
> cff8956126170d Xin Long 2020-09-29  909         net->sctp.udp6_sock = sock->sk;
#if IS_ENABLED(CONFIG_IPV6) is needed for this part.

Thanks.
> cff8956126170d Xin Long 2020-09-29  910
> 140bb5309cf409 Xin Long 2020-09-29  911         return 0;
> 140bb5309cf409 Xin Long 2020-09-29  912  }
> 140bb5309cf409 Xin Long 2020-09-29  913
>
> ---
> 0-DAY CI Kernel Test Service, Intel Corporation
> https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

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

* Re: [PATCH net-next 13/15] sctp: support for sending packet over udp4 sock
  2020-09-30  6:26                             ` Xin Long
@ 2020-09-30  6:26                               ` Xin Long
  0 siblings, 0 replies; 82+ messages in thread
From: Xin Long @ 2020-09-30  6:26 UTC (permalink / raw)
  To: kernel test robot
  Cc: network dev, linux-sctp, kbuild-all, Marcelo Ricardo Leitner,
	Neil Horman, Michael Tuexen, Tom Herbert, davem

On Wed, Sep 30, 2020 at 12:26 AM kernel test robot <lkp@intel.com> wrote:
>
> Hi Xin,
>
> Thank you for the patch! Yet something to improve:
>
> [auto build test ERROR on net-next/master]
>
> url:    https://github.com/0day-ci/linux/commits/Xin-Long/sctp-Implement-RFC6951-UDP-Encapsulation-of-SCTP/20200929-215159
> base:   https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git 280095713ce244e8dbdfb059cdca695baa72230a
> config: ia64-randconfig-r014-20200929 (attached as .config)
> compiler: ia64-linux-gcc (GCC) 9.3.0
> reproduce (this is a W=1 build):
>         wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
>         chmod +x ~/bin/make.cross
>         # https://github.com/0day-ci/linux/commit/a1016fd4a55f176fcc2eae05052a61ad7d5a142b
>         git remote add linux-review https://github.com/0day-ci/linux
>         git fetch --no-tags linux-review Xin-Long/sctp-Implement-RFC6951-UDP-Encapsulation-of-SCTP/20200929-215159
>         git checkout a1016fd4a55f176fcc2eae05052a61ad7d5a142b
>         # save the attached .config to linux build tree
>         COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=ia64
>
> If you fix the issue, kindly add following tag as appropriate
> Reported-by: kernel test robot <lkp@intel.com>
>
> All errors (new ones prefixed by >>):
>
>    net/sctp/protocol.c: In function 'sctp_udp_sock_start':
> >> net/sctp/protocol.c:894:11: error: 'struct udp_port_cfg' has no member named 'local_ip6'; did you mean 'local_ip'?
>      894 |  udp_conf.local_ip6 = in6addr_any;
>          |           ^~~~~~~~~
>          |           local_ip
>
> vim +894 net/sctp/protocol.c
>
> a330bee1c278f8 Xin Long 2020-09-29  870
> 140bb5309cf409 Xin Long 2020-09-29  871  int sctp_udp_sock_start(struct net *net)
> 140bb5309cf409 Xin Long 2020-09-29  872  {
> 140bb5309cf409 Xin Long 2020-09-29  873         struct udp_tunnel_sock_cfg tuncfg = {NULL};
> 140bb5309cf409 Xin Long 2020-09-29  874         struct udp_port_cfg udp_conf = {0};
> 140bb5309cf409 Xin Long 2020-09-29  875         struct socket *sock;
> 140bb5309cf409 Xin Long 2020-09-29  876         int err;
> 140bb5309cf409 Xin Long 2020-09-29  877
> 140bb5309cf409 Xin Long 2020-09-29  878         udp_conf.family = AF_INET;
> 140bb5309cf409 Xin Long 2020-09-29  879         udp_conf.local_ip.s_addr = htonl(INADDR_ANY);
> 140bb5309cf409 Xin Long 2020-09-29  880         udp_conf.local_udp_port = htons(net->sctp.udp_port);
> 140bb5309cf409 Xin Long 2020-09-29  881         err = udp_sock_create(net, &udp_conf, &sock);
> 140bb5309cf409 Xin Long 2020-09-29  882         if (err)
> 140bb5309cf409 Xin Long 2020-09-29  883                 return err;
> 140bb5309cf409 Xin Long 2020-09-29  884
> 140bb5309cf409 Xin Long 2020-09-29  885         tuncfg.encap_type = 1;
> 140bb5309cf409 Xin Long 2020-09-29  886         tuncfg.encap_rcv = sctp_udp_rcv;
> a330bee1c278f8 Xin Long 2020-09-29  887         tuncfg.encap_err_lookup = sctp_udp_err_lookup;
> 140bb5309cf409 Xin Long 2020-09-29  888         setup_udp_tunnel_sock(net, sock, &tuncfg);
> 140bb5309cf409 Xin Long 2020-09-29  889         net->sctp.udp4_sock = sock->sk;
> 140bb5309cf409 Xin Long 2020-09-29  890
> cff8956126170d Xin Long 2020-09-29  891         memset(&udp_conf, 0, sizeof(udp_conf));
> cff8956126170d Xin Long 2020-09-29  892
> cff8956126170d Xin Long 2020-09-29  893         udp_conf.family = AF_INET6;
> cff8956126170d Xin Long 2020-09-29 @894         udp_conf.local_ip6 = in6addr_any;
> cff8956126170d Xin Long 2020-09-29  895         udp_conf.local_udp_port = htons(net->sctp.udp_port);
> cff8956126170d Xin Long 2020-09-29  896         udp_conf.use_udp6_rx_checksums = true;
> cff8956126170d Xin Long 2020-09-29  897         udp_conf.ipv6_v6only = true;
> cff8956126170d Xin Long 2020-09-29  898         err = udp_sock_create(net, &udp_conf, &sock);
> cff8956126170d Xin Long 2020-09-29  899         if (err) {
> cff8956126170d Xin Long 2020-09-29  900                 udp_tunnel_sock_release(net->sctp.udp4_sock->sk_socket);
> cff8956126170d Xin Long 2020-09-29  901                 net->sctp.udp4_sock = NULL;
> cff8956126170d Xin Long 2020-09-29  902                 return err;
> cff8956126170d Xin Long 2020-09-29  903         }
> cff8956126170d Xin Long 2020-09-29  904
> cff8956126170d Xin Long 2020-09-29  905         tuncfg.encap_type = 1;
> cff8956126170d Xin Long 2020-09-29  906         tuncfg.encap_rcv = sctp_udp_rcv;
> a330bee1c278f8 Xin Long 2020-09-29  907         tuncfg.encap_err_lookup = sctp_udp_err_lookup;
> cff8956126170d Xin Long 2020-09-29  908         setup_udp_tunnel_sock(net, sock, &tuncfg);
> cff8956126170d Xin Long 2020-09-29  909         net->sctp.udp6_sock = sock->sk;
#if IS_ENABLED(CONFIG_IPV6) is needed for this part.

Thanks.
> cff8956126170d Xin Long 2020-09-29  910
> 140bb5309cf409 Xin Long 2020-09-29  911         return 0;
> 140bb5309cf409 Xin Long 2020-09-29  912  }
> 140bb5309cf409 Xin Long 2020-09-29  913
>
> ---
> 0-DAY CI Kernel Test Service, Intel Corporation
> https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

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

* Re: [PATCH net-next 00/15] sctp: Implement RFC6951: UDP Encapsulation of SCTP
  2020-09-29 13:48 [PATCH net-next 00/15] sctp: Implement RFC6951: UDP Encapsulation of SCTP Xin Long
                   ` (2 preceding siblings ...)
  2020-09-29 16:39 ` [PATCH net-next 00/15] sctp: Implement RFC6951: UDP Encapsulation of SCTP Michael Tuexen
@ 2020-10-01 12:41 ` Marcelo Ricardo Leitner
  2020-10-01 12:41   ` Marcelo Ricardo Leitner
  3 siblings, 1 reply; 82+ messages in thread
From: Marcelo Ricardo Leitner @ 2020-10-01 12:41 UTC (permalink / raw)
  To: Xin Long
  Cc: network dev, linux-sctp, Neil Horman, Michael Tuexen, Tom Herbert, davem

On Tue, Sep 29, 2020 at 09:48:52PM +0800, Xin Long wrote:
...
> Patches:

Please give me till tomorrow for revising this patchset.

Thanks,
Marcelo

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

* Re: [PATCH net-next 00/15] sctp: Implement RFC6951: UDP Encapsulation of SCTP
  2020-10-01 12:41 ` Marcelo Ricardo Leitner
@ 2020-10-01 12:41   ` Marcelo Ricardo Leitner
  0 siblings, 0 replies; 82+ messages in thread
From: Marcelo Ricardo Leitner @ 2020-10-01 12:41 UTC (permalink / raw)
  To: Xin Long
  Cc: network dev, linux-sctp, Neil Horman, Michael Tuexen, Tom Herbert, davem

On Tue, Sep 29, 2020 at 09:48:52PM +0800, Xin Long wrote:
...
> Patches:

Please give me till tomorrow for revising this patchset.

Thanks,
Marcelo

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

* Re: [PATCH net-next 03/15] udp: do checksum properly in skb_udp_tunnel_segment
  2020-09-29 13:48     ` [PATCH net-next 03/15] udp: do checksum properly in skb_udp_tunnel_segment Xin Long
  2020-09-29 13:48       ` Xin Long
  2020-09-29 13:48       ` [PATCH net-next 04/15] udp: support sctp over udp " Xin Long
@ 2020-10-03  4:04       ` Marcelo Ricardo Leitner
  2020-10-03  4:04         ` Marcelo Ricardo Leitner
  2020-10-03  7:40         ` Xin Long
  2 siblings, 2 replies; 82+ messages in thread
From: Marcelo Ricardo Leitner @ 2020-10-03  4:04 UTC (permalink / raw)
  To: Xin Long
  Cc: network dev, linux-sctp, Neil Horman, Michael Tuexen, Tom Herbert, davem

On Tue, Sep 29, 2020 at 09:48:55PM +0800, Xin Long wrote:
> This patch fixes two things:
> 
>   When skb->ip_summed = CHECKSUM_PARTIAL, skb_checksum_help() should be
>   called do the checksum, instead of gso_make_checksum(), which is used
>   to do the checksum for current proto after calling skb_segment(), not
>   after the inner proto's gso_segment().
> 
>   When offload_csum is disabled, the hardware will not do the checksum
>   for the current proto, udp. So instead of calling gso_make_checksum(),
>   it should calculate checksum for udp itself.

Gotta say, this is odd. It is really flipping the two around. What
about other users of this function, did you test them too?

It makes sense to be, but would be nice if someone else could review
this.

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

* Re: [PATCH net-next 03/15] udp: do checksum properly in skb_udp_tunnel_segment
  2020-10-03  4:04       ` [PATCH net-next 03/15] udp: do checksum properly in skb_udp_tunnel_segment Marcelo Ricardo Leitner
@ 2020-10-03  4:04         ` Marcelo Ricardo Leitner
  2020-10-03  7:40         ` Xin Long
  1 sibling, 0 replies; 82+ messages in thread
From: Marcelo Ricardo Leitner @ 2020-10-03  4:04 UTC (permalink / raw)
  To: Xin Long
  Cc: network dev, linux-sctp, Neil Horman, Michael Tuexen, Tom Herbert, davem

On Tue, Sep 29, 2020 at 09:48:55PM +0800, Xin Long wrote:
> This patch fixes two things:
> 
>   When skb->ip_summed == CHECKSUM_PARTIAL, skb_checksum_help() should be
>   called do the checksum, instead of gso_make_checksum(), which is used
>   to do the checksum for current proto after calling skb_segment(), not
>   after the inner proto's gso_segment().
> 
>   When offload_csum is disabled, the hardware will not do the checksum
>   for the current proto, udp. So instead of calling gso_make_checksum(),
>   it should calculate checksum for udp itself.

Gotta say, this is odd. It is really flipping the two around. What
about other users of this function, did you test them too?

It makes sense to be, but would be nice if someone else could review
this.

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

* Re: [PATCH net-next 09/15] sctp: add SCTP_REMOTE_UDP_ENCAPS_PORT sockopt
  2020-09-29 13:49                 ` [PATCH net-next 09/15] sctp: add SCTP_REMOTE_UDP_ENCAPS_PORT sockopt Xin Long
  2020-09-29 13:49                   ` Xin Long
  2020-09-29 13:49                   ` [PATCH net-next 10/15] sctp: allow changing transport encap_port by peer packets Xin Long
@ 2020-10-03  4:05                   ` Marcelo Ricardo Leitner
  2020-10-03  4:05                     ` Marcelo Ricardo Leitner
  2020-10-03  7:41                     ` Xin Long
  2 siblings, 2 replies; 82+ messages in thread
From: Marcelo Ricardo Leitner @ 2020-10-03  4:05 UTC (permalink / raw)
  To: Xin Long
  Cc: network dev, linux-sctp, Neil Horman, Michael Tuexen, Tom Herbert, davem

On Tue, Sep 29, 2020 at 09:49:01PM +0800, Xin Long wrote:
...
> +struct sctp_udpencaps {
> +	sctp_assoc_t sue_assoc_id;
> +	struct sockaddr_storage sue_address;
> +	uint16_t sue_port;
> +};
...
> +static int sctp_setsockopt_encap_port(struct sock *sk,
> +				      struct sctp_udpencaps *encap,
> +				      unsigned int optlen)
> +{
> +	struct sctp_association *asoc;
> +	struct sctp_transport *t;
> +
> +	if (optlen != sizeof(*encap))
> +		return -EINVAL;
> +
> +	/* If an address other than INADDR_ANY is specified, and
> +	 * no transport is found, then the request is invalid.
> +	 */
> +	if (!sctp_is_any(sk, (union sctp_addr *)&encap->sue_address)) {
> +		t = sctp_addr_id2transport(sk, &encap->sue_address,
> +					   encap->sue_assoc_id);
> +		if (!t)
> +			return -EINVAL;
> +
> +		t->encap_port = encap->sue_port;
                   ^^^^^^^^^^          ^^^^^^^^

encap_port is defined as __u16 is previous patch, but from RFC:
  sue_port:  The UDP port number in network byte order...

asoc->peer.port is stored in host order, so it makes sense to follow
it here. Then need a htons() here and its counter parts.  It is right
in some parts of the patches already.

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

* Re: [PATCH net-next 09/15] sctp: add SCTP_REMOTE_UDP_ENCAPS_PORT sockopt
  2020-10-03  4:05                   ` [PATCH net-next 09/15] sctp: add SCTP_REMOTE_UDP_ENCAPS_PORT sockopt Marcelo Ricardo Leitner
@ 2020-10-03  4:05                     ` Marcelo Ricardo Leitner
  2020-10-03  7:41                     ` Xin Long
  1 sibling, 0 replies; 82+ messages in thread
From: Marcelo Ricardo Leitner @ 2020-10-03  4:05 UTC (permalink / raw)
  To: Xin Long
  Cc: network dev, linux-sctp, Neil Horman, Michael Tuexen, Tom Herbert, davem

On Tue, Sep 29, 2020 at 09:49:01PM +0800, Xin Long wrote:
...
> +struct sctp_udpencaps {
> +	sctp_assoc_t sue_assoc_id;
> +	struct sockaddr_storage sue_address;
> +	uint16_t sue_port;
> +};
...
> +static int sctp_setsockopt_encap_port(struct sock *sk,
> +				      struct sctp_udpencaps *encap,
> +				      unsigned int optlen)
> +{
> +	struct sctp_association *asoc;
> +	struct sctp_transport *t;
> +
> +	if (optlen != sizeof(*encap))
> +		return -EINVAL;
> +
> +	/* If an address other than INADDR_ANY is specified, and
> +	 * no transport is found, then the request is invalid.
> +	 */
> +	if (!sctp_is_any(sk, (union sctp_addr *)&encap->sue_address)) {
> +		t = sctp_addr_id2transport(sk, &encap->sue_address,
> +					   encap->sue_assoc_id);
> +		if (!t)
> +			return -EINVAL;
> +
> +		t->encap_port = encap->sue_port;
                   ^^^^^^^^^^          ^^^^^^^^

encap_port is defined as __u16 is previous patch, but from RFC:
  sue_port:  The UDP port number in network byte order...

asoc->peer.port is stored in host order, so it makes sense to follow
it here. Then need a htons() here and its counter parts.  It is right
in some parts of the patches already.

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

* Re: [PATCH net-next 10/15] sctp: allow changing transport encap_port by peer packets
  2020-09-29 13:49                   ` [PATCH net-next 10/15] sctp: allow changing transport encap_port by peer packets Xin Long
  2020-09-29 13:49                     ` Xin Long
  2020-09-29 13:49                     ` [PATCH net-next 11/15] sctp: add udphdr to overhead when udp_port is set Xin Long
@ 2020-10-03  4:06                     ` Marcelo Ricardo Leitner
  2020-10-03  4:06                       ` Marcelo Ricardo Leitner
  2 siblings, 1 reply; 82+ messages in thread
From: Marcelo Ricardo Leitner @ 2020-10-03  4:06 UTC (permalink / raw)
  To: Xin Long
  Cc: network dev, linux-sctp, Neil Horman, Michael Tuexen, Tom Herbert, davem

On Tue, Sep 29, 2020 at 09:49:02PM +0800, Xin Long wrote:
>  static int sctp_udp_rcv(struct sock *sk, struct sk_buff *skb)
>  {
> +	memset(skb->cb, 0, sizeof(skb->cb));
> +	SCTP_INPUT_CB(skb)->encap_port = ntohs(udp_hdr(skb)->source);

Here it's in host order already. The fact that is does this
transparent update probably hid the other issue.

> +
>  	skb_set_transport_header(skb, sizeof(struct udphdr));
>  	sctp_rcv(skb);
>  	return 0;

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

* Re: [PATCH net-next 10/15] sctp: allow changing transport encap_port by peer packets
  2020-10-03  4:06                     ` [PATCH net-next 10/15] sctp: allow changing transport encap_port by peer packets Marcelo Ricardo Leitner
@ 2020-10-03  4:06                       ` Marcelo Ricardo Leitner
  0 siblings, 0 replies; 82+ messages in thread
From: Marcelo Ricardo Leitner @ 2020-10-03  4:06 UTC (permalink / raw)
  To: Xin Long
  Cc: network dev, linux-sctp, Neil Horman, Michael Tuexen, Tom Herbert, davem

On Tue, Sep 29, 2020 at 09:49:02PM +0800, Xin Long wrote:
>  static int sctp_udp_rcv(struct sock *sk, struct sk_buff *skb)
>  {
> +	memset(skb->cb, 0, sizeof(skb->cb));
> +	SCTP_INPUT_CB(skb)->encap_port = ntohs(udp_hdr(skb)->source);

Here it's in host order already. The fact that is does this
transparent update probably hid the other issue.

> +
>  	skb_set_transport_header(skb, sizeof(struct udphdr));
>  	sctp_rcv(skb);
>  	return 0;

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

* Re: [PATCH net-next 11/15] sctp: add udphdr to overhead when udp_port is set
  2020-09-29 13:49                     ` [PATCH net-next 11/15] sctp: add udphdr to overhead when udp_port is set Xin Long
                                         ` (2 preceding siblings ...)
  2020-09-29 19:00                       ` [PATCH net-next 11/15] sctp: add udphdr to overhead when udp_port is set kernel test robot
@ 2020-10-03  4:07                       ` Marcelo Ricardo Leitner
  2020-10-03  4:07                         ` Marcelo Ricardo Leitner
  2020-10-03  7:54                         ` Xin Long
  3 siblings, 2 replies; 82+ messages in thread
From: Marcelo Ricardo Leitner @ 2020-10-03  4:07 UTC (permalink / raw)
  To: Xin Long
  Cc: network dev, linux-sctp, Neil Horman, Michael Tuexen, Tom Herbert, davem

On Tue, Sep 29, 2020 at 09:49:03PM +0800, Xin Long wrote:
> sctp_mtu_payload() is for calculating the frag size before making
> chunks from a msg. So we should only add udphdr size to overhead
> when udp socks are listening, as only then sctp can handling the
                                               "handle"   ^^^^
> incoming sctp over udp packets and outgoing sctp over udp packets
> will be possible.
> 
> Note that we can't do this according to transport->encap_port, as
> different transports may be set to different values, while the
> chunks were made before choosing the transport, we could not be
> able to meet all rfc6951#section-5.6 requires.

I don't follow this last part. I guess you're referring to the fact
that it won't grow back the PMTU if it is not encapsulating anymore.
If that's it, then changelog should be different here.  As is, it
seems it is not abiding by the RFC, but it is, as that's a 'SHOULD'.

Maybe s/requires\.$/recommends./ ?

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

* Re: [PATCH net-next 11/15] sctp: add udphdr to overhead when udp_port is set
  2020-10-03  4:07                       ` Marcelo Ricardo Leitner
@ 2020-10-03  4:07                         ` Marcelo Ricardo Leitner
  2020-10-03  7:54                         ` Xin Long
  1 sibling, 0 replies; 82+ messages in thread
From: Marcelo Ricardo Leitner @ 2020-10-03  4:07 UTC (permalink / raw)
  To: Xin Long
  Cc: network dev, linux-sctp, Neil Horman, Michael Tuexen, Tom Herbert, davem

On Tue, Sep 29, 2020 at 09:49:03PM +0800, Xin Long wrote:
> sctp_mtu_payload() is for calculating the frag size before making
> chunks from a msg. So we should only add udphdr size to overhead
> when udp socks are listening, as only then sctp can handling the
                                               "handle"   ^^^^
> incoming sctp over udp packets and outgoing sctp over udp packets
> will be possible.
> 
> Note that we can't do this according to transport->encap_port, as
> different transports may be set to different values, while the
> chunks were made before choosing the transport, we could not be
> able to meet all rfc6951#section-5.6 requires.

I don't follow this last part. I guess you're referring to the fact
that it won't grow back the PMTU if it is not encapsulating anymore.
If that's it, then changelog should be different here.  As is, it
seems it is not abiding by the RFC, but it is, as that's a 'SHOULD'.

Maybe s/requires\.$/recommends./ ?

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

* Re: [PATCH net-next 11/15] sctp: add udphdr to overhead when udp_port is set
  2020-09-29 19:00                       ` [PATCH net-next 11/15] sctp: add udphdr to overhead when udp_port is set kernel test robot
  2020-09-29 19:00                         ` kernel test robot
@ 2020-10-03  4:08                         ` Marcelo Ricardo Leitner
  2020-10-03  4:08                           ` Marcelo Ricardo Leitner
  2020-10-03  7:57                           ` Xin Long
  1 sibling, 2 replies; 82+ messages in thread
From: Marcelo Ricardo Leitner @ 2020-10-03  4:08 UTC (permalink / raw)
  To: kernel test robot
  Cc: Xin Long, network dev, linux-sctp, kbuild-all, Neil Horman,
	Michael Tuexen, Tom Herbert, davem

On Wed, Sep 30, 2020 at 03:00:42AM +0800, kernel test robot wrote:
> Hi Xin,
> 
> Thank you for the patch! Yet something to improve:

I wonder how are you planning to fix this. It is quite entangled.
This is not performance critical. Maybe the cleanest way out is to
move it to a .c file.

Adding a
#if defined(CONFIG_IP_SCTP) || defined(CONFIG_IP_SCTP_MODULE)
in there doesn't seem good.

>    In file included from include/net/sctp/checksum.h:27,
>                     from net/netfilter/nf_nat_proto.c:16:
>    include/net/sctp/sctp.h: In function 'sctp_mtu_payload':
> >> include/net/sctp/sctp.h:583:31: error: 'struct net' has no member named 'sctp'; did you mean 'ct'?
>      583 |   if (sock_net(&sp->inet.sk)->sctp.udp_port)
>          |                               ^~~~
>          |                               ct
> 

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

* Re: [PATCH net-next 11/15] sctp: add udphdr to overhead when udp_port is set
  2020-10-03  4:08                         ` Marcelo Ricardo Leitner
@ 2020-10-03  4:08                           ` Marcelo Ricardo Leitner
  2020-10-03  7:57                           ` Xin Long
  1 sibling, 0 replies; 82+ messages in thread
From: Marcelo Ricardo Leitner @ 2020-10-03  4:08 UTC (permalink / raw)
  To: kernel test robot
  Cc: Xin Long, network dev, linux-sctp, kbuild-all, Neil Horman,
	Michael Tuexen, Tom Herbert, davem

On Wed, Sep 30, 2020 at 03:00:42AM +0800, kernel test robot wrote:
> Hi Xin,
> 
> Thank you for the patch! Yet something to improve:

I wonder how are you planning to fix this. It is quite entangled.
This is not performance critical. Maybe the cleanest way out is to
move it to a .c file.

Adding a
#if defined(CONFIG_IP_SCTP) || defined(CONFIG_IP_SCTP_MODULE)
in there doesn't seem good.

>    In file included from include/net/sctp/checksum.h:27,
>                     from net/netfilter/nf_nat_proto.c:16:
>    include/net/sctp/sctp.h: In function 'sctp_mtu_payload':
> >> include/net/sctp/sctp.h:583:31: error: 'struct net' has no member named 'sctp'; did you mean 'ct'?
>      583 |   if (sock_net(&sp->inet.sk)->sctp.udp_port)
>          |                               ^~~~
>          |                               ct
> 

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

* Re: [PATCH net-next 12/15] sctp: call sk_setup_caps in sctp_packet_transmit instead
  2020-09-29 13:49                       ` [PATCH net-next 12/15] sctp: call sk_setup_caps in sctp_packet_transmit instead Xin Long
  2020-09-29 13:49                         ` Xin Long
  2020-09-29 13:49                         ` [PATCH net-next 13/15] sctp: support for sending packet over udp4 sock Xin Long
@ 2020-10-03  4:09                         ` Marcelo Ricardo Leitner
  2020-10-03  4:09                           ` Marcelo Ricardo Leitner
  2020-10-03  7:45                           ` Xin Long
  2 siblings, 2 replies; 82+ messages in thread
From: Marcelo Ricardo Leitner @ 2020-10-03  4:09 UTC (permalink / raw)
  To: Xin Long
  Cc: network dev, linux-sctp, Neil Horman, Michael Tuexen, Tom Herbert, davem

On Tue, Sep 29, 2020 at 09:49:04PM +0800, Xin Long wrote:
> sk_setup_caps() was originally called in Commit 90017accff61 ("sctp:
> Add GSO support"), as:
> 
>   "We have to refresh this in case we are xmiting to more than one
>    transport at a time"
> 
> This actually happens in the loop of sctp_outq_flush_transports(),
> and it shouldn't be gso related, so move it out of gso part and

To be more precise, "shouldn't be tied to gso"

> before sctp_packet_pack().

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

* Re: [PATCH net-next 12/15] sctp: call sk_setup_caps in sctp_packet_transmit instead
  2020-10-03  4:09                         ` [PATCH net-next 12/15] sctp: call sk_setup_caps in sctp_packet_transmit instead Marcelo Ricardo Leitner
@ 2020-10-03  4:09                           ` Marcelo Ricardo Leitner
  2020-10-03  7:45                           ` Xin Long
  1 sibling, 0 replies; 82+ messages in thread
From: Marcelo Ricardo Leitner @ 2020-10-03  4:09 UTC (permalink / raw)
  To: Xin Long
  Cc: network dev, linux-sctp, Neil Horman, Michael Tuexen, Tom Herbert, davem

On Tue, Sep 29, 2020 at 09:49:04PM +0800, Xin Long wrote:
> sk_setup_caps() was originally called in Commit 90017accff61 ("sctp:
> Add GSO support"), as:
> 
>   "We have to refresh this in case we are xmiting to more than one
>    transport at a time"
> 
> This actually happens in the loop of sctp_outq_flush_transports(),
> and it shouldn't be gso related, so move it out of gso part and

To be more precise, "shouldn't be tied to gso"

> before sctp_packet_pack().

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

* Re: [PATCH net-next 15/15] sctp: enable udp tunneling socks
  2020-09-29 13:49                             ` [PATCH net-next 15/15] sctp: enable udp tunneling socks Xin Long
  2020-09-29 13:49                               ` Xin Long
@ 2020-10-03  4:12                               ` Marcelo Ricardo Leitner
  2020-10-03  4:12                                 ` Marcelo Ricardo Leitner
  2020-10-03  8:20                                 ` Xin Long
  1 sibling, 2 replies; 82+ messages in thread
From: Marcelo Ricardo Leitner @ 2020-10-03  4:12 UTC (permalink / raw)
  To: Xin Long
  Cc: network dev, linux-sctp, Neil Horman, Michael Tuexen, Tom Herbert, davem

On Tue, Sep 29, 2020 at 09:49:07PM +0800, Xin Long wrote:
> This patch is to enable udp tunneling socks by calling
> sctp_udp_sock_start() in sctp_ctrlsock_init(), and
> sctp_udp_sock_stop() in sctp_ctrlsock_exit().
> 
> Also add sysctl udp_port to allow changing the listening
> sock's port by users.
> 
> Wit this patch, the whole sctp over udp feature can be
  With

> enabled and used.
...
> @@ -1466,6 +1466,10 @@ static int __net_init sctp_ctrlsock_init(struct net *net)
>  	if (status)
>  		pr_err("Failed to initialize the SCTP control sock\n");
>  
> +	status = sctp_udp_sock_start(net);

This can be masking the previous error.

> +	if (status)
> +		pr_err("Failed to initialize the SCTP udp tunneling sock\n");
                                                 SCTP UDP

> +
>  	return status;
>  }
>  

This is the last comment I had.
Thanks Xin! Nice patches.

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

* Re: [PATCH net-next 15/15] sctp: enable udp tunneling socks
  2020-10-03  4:12                               ` Marcelo Ricardo Leitner
@ 2020-10-03  4:12                                 ` Marcelo Ricardo Leitner
  2020-10-03  8:20                                 ` Xin Long
  1 sibling, 0 replies; 82+ messages in thread
From: Marcelo Ricardo Leitner @ 2020-10-03  4:12 UTC (permalink / raw)
  To: Xin Long
  Cc: network dev, linux-sctp, Neil Horman, Michael Tuexen, Tom Herbert, davem

On Tue, Sep 29, 2020 at 09:49:07PM +0800, Xin Long wrote:
> This patch is to enable udp tunneling socks by calling
> sctp_udp_sock_start() in sctp_ctrlsock_init(), and
> sctp_udp_sock_stop() in sctp_ctrlsock_exit().
> 
> Also add sysctl udp_port to allow changing the listening
> sock's port by users.
> 
> Wit this patch, the whole sctp over udp feature can be
  With

> enabled and used.
...
> @@ -1466,6 +1466,10 @@ static int __net_init sctp_ctrlsock_init(struct net *net)
>  	if (status)
>  		pr_err("Failed to initialize the SCTP control sock\n");
>  
> +	status = sctp_udp_sock_start(net);

This can be masking the previous error.

> +	if (status)
> +		pr_err("Failed to initialize the SCTP udp tunneling sock\n");
                                                 SCTP UDP

> +
>  	return status;
>  }
>  

This is the last comment I had.
Thanks Xin! Nice patches.

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

* Re: [PATCH net-next 03/15] udp: do checksum properly in skb_udp_tunnel_segment
  2020-10-03  4:04       ` [PATCH net-next 03/15] udp: do checksum properly in skb_udp_tunnel_segment Marcelo Ricardo Leitner
  2020-10-03  4:04         ` Marcelo Ricardo Leitner
@ 2020-10-03  7:40         ` Xin Long
  2020-10-03  7:40           ` Xin Long
  1 sibling, 1 reply; 82+ messages in thread
From: Xin Long @ 2020-10-03  7:40 UTC (permalink / raw)
  To: Marcelo Ricardo Leitner
  Cc: network dev, linux-sctp, Neil Horman, Michael Tuexen, davem, tom

On Sat, Oct 3, 2020 at 12:04 PM Marcelo Ricardo Leitner
<marcelo.leitner@gmail.com> wrote:
>
> On Tue, Sep 29, 2020 at 09:48:55PM +0800, Xin Long wrote:
> > This patch fixes two things:
> >
> >   When skb->ip_summed = CHECKSUM_PARTIAL, skb_checksum_help() should be
> >   called do the checksum, instead of gso_make_checksum(), which is used
> >   to do the checksum for current proto after calling skb_segment(), not
> >   after the inner proto's gso_segment().
> >
> >   When offload_csum is disabled, the hardware will not do the checksum
> >   for the current proto, udp. So instead of calling gso_make_checksum(),
> >   it should calculate checksum for udp itself.
>
> Gotta say, this is odd. It is really flipping the two around. What
> about other users of this function, did you test them too?
Not yet, I couldn't found other cases to trigger this.

But I think gso_make_checksum() is not correct to be used here,
as it's trying to calculate the checksum for inner protocol
instead of UDP's. It should be skb_checksum_help(), like on
the xmit path.

>
> It makes sense to be, but would be nice if someone else could review
> this.
Fix the mail of Tom Herbert, and he is the right person to review this.

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

* Re: [PATCH net-next 03/15] udp: do checksum properly in skb_udp_tunnel_segment
  2020-10-03  7:40         ` Xin Long
@ 2020-10-03  7:40           ` Xin Long
  0 siblings, 0 replies; 82+ messages in thread
From: Xin Long @ 2020-10-03  7:40 UTC (permalink / raw)
  To: Marcelo Ricardo Leitner
  Cc: network dev, linux-sctp, Neil Horman, Michael Tuexen, davem, tom

On Sat, Oct 3, 2020 at 12:04 PM Marcelo Ricardo Leitner
<marcelo.leitner@gmail.com> wrote:
>
> On Tue, Sep 29, 2020 at 09:48:55PM +0800, Xin Long wrote:
> > This patch fixes two things:
> >
> >   When skb->ip_summed == CHECKSUM_PARTIAL, skb_checksum_help() should be
> >   called do the checksum, instead of gso_make_checksum(), which is used
> >   to do the checksum for current proto after calling skb_segment(), not
> >   after the inner proto's gso_segment().
> >
> >   When offload_csum is disabled, the hardware will not do the checksum
> >   for the current proto, udp. So instead of calling gso_make_checksum(),
> >   it should calculate checksum for udp itself.
>
> Gotta say, this is odd. It is really flipping the two around. What
> about other users of this function, did you test them too?
Not yet, I couldn't found other cases to trigger this.

But I think gso_make_checksum() is not correct to be used here,
as it's trying to calculate the checksum for inner protocol
instead of UDP's. It should be skb_checksum_help(), like on
the xmit path.

>
> It makes sense to be, but would be nice if someone else could review
> this.
Fix the mail of Tom Herbert, and he is the right person to review this.

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

* Re: [PATCH net-next 09/15] sctp: add SCTP_REMOTE_UDP_ENCAPS_PORT sockopt
  2020-10-03  4:05                   ` [PATCH net-next 09/15] sctp: add SCTP_REMOTE_UDP_ENCAPS_PORT sockopt Marcelo Ricardo Leitner
  2020-10-03  4:05                     ` Marcelo Ricardo Leitner
@ 2020-10-03  7:41                     ` Xin Long
  2020-10-03  7:41                       ` Xin Long
  1 sibling, 1 reply; 82+ messages in thread
From: Xin Long @ 2020-10-03  7:41 UTC (permalink / raw)
  To: Marcelo Ricardo Leitner
  Cc: network dev, linux-sctp, Neil Horman, Michael Tuexen, Tom Herbert, davem

On Sat, Oct 3, 2020 at 12:05 PM Marcelo Ricardo Leitner
<marcelo.leitner@gmail.com> wrote:
>
> On Tue, Sep 29, 2020 at 09:49:01PM +0800, Xin Long wrote:
> ...
> > +struct sctp_udpencaps {
> > +     sctp_assoc_t sue_assoc_id;
> > +     struct sockaddr_storage sue_address;
> > +     uint16_t sue_port;
> > +};
> ...
> > +static int sctp_setsockopt_encap_port(struct sock *sk,
> > +                                   struct sctp_udpencaps *encap,
> > +                                   unsigned int optlen)
> > +{
> > +     struct sctp_association *asoc;
> > +     struct sctp_transport *t;
> > +
> > +     if (optlen != sizeof(*encap))
> > +             return -EINVAL;
> > +
> > +     /* If an address other than INADDR_ANY is specified, and
> > +      * no transport is found, then the request is invalid.
> > +      */
> > +     if (!sctp_is_any(sk, (union sctp_addr *)&encap->sue_address)) {
> > +             t = sctp_addr_id2transport(sk, &encap->sue_address,
> > +                                        encap->sue_assoc_id);
> > +             if (!t)
> > +                     return -EINVAL;
> > +
> > +             t->encap_port = encap->sue_port;
>                    ^^^^^^^^^^          ^^^^^^^^
>
> encap_port is defined as __u16 is previous patch, but from RFC:
>   sue_port:  The UDP port number in network byte order...
>
> asoc->peer.port is stored in host order, so it makes sense to follow
> it here. Then need a htons() here and its counter parts.  It is right
> in some parts of the patches already.
Good catch! thank you!

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

* Re: [PATCH net-next 09/15] sctp: add SCTP_REMOTE_UDP_ENCAPS_PORT sockopt
  2020-10-03  7:41                     ` Xin Long
@ 2020-10-03  7:41                       ` Xin Long
  0 siblings, 0 replies; 82+ messages in thread
From: Xin Long @ 2020-10-03  7:41 UTC (permalink / raw)
  To: Marcelo Ricardo Leitner
  Cc: network dev, linux-sctp, Neil Horman, Michael Tuexen, Tom Herbert, davem

On Sat, Oct 3, 2020 at 12:05 PM Marcelo Ricardo Leitner
<marcelo.leitner@gmail.com> wrote:
>
> On Tue, Sep 29, 2020 at 09:49:01PM +0800, Xin Long wrote:
> ...
> > +struct sctp_udpencaps {
> > +     sctp_assoc_t sue_assoc_id;
> > +     struct sockaddr_storage sue_address;
> > +     uint16_t sue_port;
> > +};
> ...
> > +static int sctp_setsockopt_encap_port(struct sock *sk,
> > +                                   struct sctp_udpencaps *encap,
> > +                                   unsigned int optlen)
> > +{
> > +     struct sctp_association *asoc;
> > +     struct sctp_transport *t;
> > +
> > +     if (optlen != sizeof(*encap))
> > +             return -EINVAL;
> > +
> > +     /* If an address other than INADDR_ANY is specified, and
> > +      * no transport is found, then the request is invalid.
> > +      */
> > +     if (!sctp_is_any(sk, (union sctp_addr *)&encap->sue_address)) {
> > +             t = sctp_addr_id2transport(sk, &encap->sue_address,
> > +                                        encap->sue_assoc_id);
> > +             if (!t)
> > +                     return -EINVAL;
> > +
> > +             t->encap_port = encap->sue_port;
>                    ^^^^^^^^^^          ^^^^^^^^
>
> encap_port is defined as __u16 is previous patch, but from RFC:
>   sue_port:  The UDP port number in network byte order...
>
> asoc->peer.port is stored in host order, so it makes sense to follow
> it here. Then need a htons() here and its counter parts.  It is right
> in some parts of the patches already.
Good catch! thank you!

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

* Re: [PATCH net-next 12/15] sctp: call sk_setup_caps in sctp_packet_transmit instead
  2020-10-03  4:09                         ` [PATCH net-next 12/15] sctp: call sk_setup_caps in sctp_packet_transmit instead Marcelo Ricardo Leitner
  2020-10-03  4:09                           ` Marcelo Ricardo Leitner
@ 2020-10-03  7:45                           ` Xin Long
  2020-10-03  7:45                             ` Xin Long
  1 sibling, 1 reply; 82+ messages in thread
From: Xin Long @ 2020-10-03  7:45 UTC (permalink / raw)
  To: Marcelo Ricardo Leitner
  Cc: network dev, linux-sctp, Neil Horman, Michael Tuexen, Tom Herbert, davem

On Sat, Oct 3, 2020 at 12:09 PM Marcelo Ricardo Leitner
<marcelo.leitner@gmail.com> wrote:
>
> On Tue, Sep 29, 2020 at 09:49:04PM +0800, Xin Long wrote:
> > sk_setup_caps() was originally called in Commit 90017accff61 ("sctp:
> > Add GSO support"), as:
> >
> >   "We have to refresh this in case we are xmiting to more than one
> >    transport at a time"
> >
> > This actually happens in the loop of sctp_outq_flush_transports(),
> > and it shouldn't be gso related, so move it out of gso part and
>
> To be more precise, "shouldn't be tied to gso"
right.

>
> > before sctp_packet_pack().

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

* Re: [PATCH net-next 12/15] sctp: call sk_setup_caps in sctp_packet_transmit instead
  2020-10-03  7:45                           ` Xin Long
@ 2020-10-03  7:45                             ` Xin Long
  0 siblings, 0 replies; 82+ messages in thread
From: Xin Long @ 2020-10-03  7:45 UTC (permalink / raw)
  To: Marcelo Ricardo Leitner
  Cc: network dev, linux-sctp, Neil Horman, Michael Tuexen, Tom Herbert, davem

On Sat, Oct 3, 2020 at 12:09 PM Marcelo Ricardo Leitner
<marcelo.leitner@gmail.com> wrote:
>
> On Tue, Sep 29, 2020 at 09:49:04PM +0800, Xin Long wrote:
> > sk_setup_caps() was originally called in Commit 90017accff61 ("sctp:
> > Add GSO support"), as:
> >
> >   "We have to refresh this in case we are xmiting to more than one
> >    transport at a time"
> >
> > This actually happens in the loop of sctp_outq_flush_transports(),
> > and it shouldn't be gso related, so move it out of gso part and
>
> To be more precise, "shouldn't be tied to gso"
right.

>
> > before sctp_packet_pack().

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

* Re: [PATCH net-next 11/15] sctp: add udphdr to overhead when udp_port is set
  2020-10-03  4:07                       ` Marcelo Ricardo Leitner
  2020-10-03  4:07                         ` Marcelo Ricardo Leitner
@ 2020-10-03  7:54                         ` Xin Long
  2020-10-03  7:54                           ` Xin Long
  1 sibling, 1 reply; 82+ messages in thread
From: Xin Long @ 2020-10-03  7:54 UTC (permalink / raw)
  To: Marcelo Ricardo Leitner
  Cc: network dev, linux-sctp, Neil Horman, Michael Tuexen, Tom Herbert, davem

On Sat, Oct 3, 2020 at 12:07 PM Marcelo Ricardo Leitner
<marcelo.leitner@gmail.com> wrote:
>
> On Tue, Sep 29, 2020 at 09:49:03PM +0800, Xin Long wrote:
> > sctp_mtu_payload() is for calculating the frag size before making
> > chunks from a msg. So we should only add udphdr size to overhead
> > when udp socks are listening, as only then sctp can handling the
>                                                "handle"   ^^^^
right. :D
> > incoming sctp over udp packets and outgoing sctp over udp packets
> > will be possible.
> >
> > Note that we can't do this according to transport->encap_port, as
> > different transports may be set to different values, while the
> > chunks were made before choosing the transport, we could not be
> > able to meet all rfc6951#section-5.6 requires.
>
> I don't follow this last part. I guess you're referring to the fact
> that it won't grow back the PMTU if it is not encapsulating anymore.
> If that's it, then changelog should be different here.  As is, it
> seems it is not abiding by the RFC, but it is, as that's a 'SHOULD'.
>
> Maybe s/requires\.$/recommends./ ?
Yes, it's a "should".

What the code can only do is "the Path MTU SHOULD be increased by
the size of the UDP header" when udp listening port is disabled.

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

* Re: [PATCH net-next 11/15] sctp: add udphdr to overhead when udp_port is set
  2020-10-03  7:54                         ` Xin Long
@ 2020-10-03  7:54                           ` Xin Long
  0 siblings, 0 replies; 82+ messages in thread
From: Xin Long @ 2020-10-03  7:54 UTC (permalink / raw)
  To: Marcelo Ricardo Leitner
  Cc: network dev, linux-sctp, Neil Horman, Michael Tuexen, Tom Herbert, davem

On Sat, Oct 3, 2020 at 12:07 PM Marcelo Ricardo Leitner
<marcelo.leitner@gmail.com> wrote:
>
> On Tue, Sep 29, 2020 at 09:49:03PM +0800, Xin Long wrote:
> > sctp_mtu_payload() is for calculating the frag size before making
> > chunks from a msg. So we should only add udphdr size to overhead
> > when udp socks are listening, as only then sctp can handling the
>                                                "handle"   ^^^^
right. :D
> > incoming sctp over udp packets and outgoing sctp over udp packets
> > will be possible.
> >
> > Note that we can't do this according to transport->encap_port, as
> > different transports may be set to different values, while the
> > chunks were made before choosing the transport, we could not be
> > able to meet all rfc6951#section-5.6 requires.
>
> I don't follow this last part. I guess you're referring to the fact
> that it won't grow back the PMTU if it is not encapsulating anymore.
> If that's it, then changelog should be different here.  As is, it
> seems it is not abiding by the RFC, but it is, as that's a 'SHOULD'.
>
> Maybe s/requires\.$/recommends./ ?
Yes, it's a "should".

What the code can only do is "the Path MTU SHOULD be increased by
the size of the UDP header" when udp listening port is disabled.

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

* Re: [PATCH net-next 11/15] sctp: add udphdr to overhead when udp_port is set
  2020-10-03  4:08                         ` Marcelo Ricardo Leitner
  2020-10-03  4:08                           ` Marcelo Ricardo Leitner
@ 2020-10-03  7:57                           ` Xin Long
  2020-10-03  8:12                             ` Xin Long
  2020-10-03 11:23                             ` Xin Long
  1 sibling, 2 replies; 82+ messages in thread
From: Xin Long @ 2020-10-03  7:57 UTC (permalink / raw)
  To: Marcelo Ricardo Leitner
  Cc: kernel test robot, network dev, linux-sctp, kbuild-all,
	Neil Horman, Michael Tuexen, Tom Herbert, davem

On Sat, Oct 3, 2020 at 12:08 PM Marcelo Ricardo Leitner
<marcelo.leitner@gmail.com> wrote:
>
> On Wed, Sep 30, 2020 at 03:00:42AM +0800, kernel test robot wrote:
> > Hi Xin,
> >
> > Thank you for the patch! Yet something to improve:
>
> I wonder how are you planning to fix this. It is quite entangled.
> This is not performance critical. Maybe the cleanest way out is to
> move it to a .c file.
>
> Adding a
> #if defined(CONFIG_IP_SCTP) || defined(CONFIG_IP_SCTP_MODULE)
> in there doesn't seem good.
>
> >    In file included from include/net/sctp/checksum.h:27,
> >                     from net/netfilter/nf_nat_proto.c:16:
> >    include/net/sctp/sctp.h: In function 'sctp_mtu_payload':
> > >> include/net/sctp/sctp.h:583:31: error: 'struct net' has no member named 'sctp'; did you mean 'ct'?
> >      583 |   if (sock_net(&sp->inet.sk)->sctp.udp_port)
> >          |                               ^~~~
> >          |                               ct
> >
Here is actually another problem, I'm still thinking how to fix it.

Now sctp_mtu_payload() returns different value depending on
net->sctp.udp_port. but net->sctp.udp_port can be changed by
"sysctl -w" anytime. so:

In sctp_packet_config() it gets overhead/headroom by calling
sctp_mtu_payload(). When 'udp_port' is 0, it's IP+MAC header
size. Then if 'udp_port' is changed to 9899 by 'sysctl -w',
udphdr will also be added to the packet in sctp_v4_xmit(),
and later the headroom may not be enough for IP+MAC headers.

I'm thinking to add sctp_sock->udp_port, and it'll be set when
the sock is created with net->udp_port. but not sure if we should
update sctp_sock->udp_port with  net->udp_port when sending packets?

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

* Re: [PATCH net-next 11/15] sctp: add udphdr to overhead when udp_port is set
  2020-10-03  7:57                           ` Xin Long
@ 2020-10-03  8:12                             ` Xin Long
  2020-10-03 11:23                             ` Xin Long
  1 sibling, 0 replies; 82+ messages in thread
From: Xin Long @ 2020-10-03  8:12 UTC (permalink / raw)
  To: Marcelo Ricardo Leitner
  Cc: kernel test robot, network dev, linux-sctp, kbuild-all,
	Neil Horman, Michael Tuexen, Tom Herbert, davem

On Sat, Oct 3, 2020 at 12:08 PM Marcelo Ricardo Leitner
<marcelo.leitner@gmail.com> wrote:
>
> On Wed, Sep 30, 2020 at 03:00:42AM +0800, kernel test robot wrote:
> > Hi Xin,
> >
> > Thank you for the patch! Yet something to improve:
>
> I wonder how are you planning to fix this. It is quite entangled.
> This is not performance critical. Maybe the cleanest way out is to
> move it to a .c file.
>
> Adding a
> #if defined(CONFIG_IP_SCTP) || defined(CONFIG_IP_SCTP_MODULE)
> in there doesn't seem good.
>
> >    In file included from include/net/sctp/checksum.h:27,
> >                     from net/netfilter/nf_nat_proto.c:16:
> >    include/net/sctp/sctp.h: In function 'sctp_mtu_payload':
> > >> include/net/sctp/sctp.h:583:31: error: 'struct net' has no member named 'sctp'; did you mean 'ct'?
> >      583 |   if (sock_net(&sp->inet.sk)->sctp.udp_port)
> >          |                               ^~~~
> >          |                               ct
> >
Here is actually another problem, I'm still thinking how to fix it.

Now sctp_mtu_payload() returns different value depending on
net->sctp.udp_port. but net->sctp.udp_port can be changed by
"sysctl -w" anytime. so:

In sctp_packet_config() it gets overhead/headroom by calling
sctp_mtu_payload(). When 'udp_port' is 0, it's IP+MAC header
size. Then if 'udp_port' is changed to 9899 by 'sysctl -w',
udphdr will also be added to the packet in sctp_v4_xmit(),
and later the headroom may not be enough for IP+MAC headers.

I'm thinking to add sctp_sock->udp_port, and it'll be set when
the sock is created with net->udp_port. but not sure if we should
update sctp_sock->udp_port with  net->udp_port when sending packets?

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

* Re: [PATCH net-next 15/15] sctp: enable udp tunneling socks
  2020-10-03  4:12                               ` Marcelo Ricardo Leitner
  2020-10-03  4:12                                 ` Marcelo Ricardo Leitner
@ 2020-10-03  8:20                                 ` Xin Long
  2020-10-03  8:20                                   ` Xin Long
  1 sibling, 1 reply; 82+ messages in thread
From: Xin Long @ 2020-10-03  8:20 UTC (permalink / raw)
  To: Marcelo Ricardo Leitner
  Cc: network dev, linux-sctp, Neil Horman, Michael Tuexen, Tom Herbert, davem

On Sat, Oct 3, 2020 at 12:12 PM Marcelo Ricardo Leitner
<marcelo.leitner@gmail.com> wrote:
>
> On Tue, Sep 29, 2020 at 09:49:07PM +0800, Xin Long wrote:
> > This patch is to enable udp tunneling socks by calling
> > sctp_udp_sock_start() in sctp_ctrlsock_init(), and
> > sctp_udp_sock_stop() in sctp_ctrlsock_exit().
> >
> > Also add sysctl udp_port to allow changing the listening
> > sock's port by users.
> >
> > Wit this patch, the whole sctp over udp feature can be
>   With
>
> > enabled and used.
> ...
> > @@ -1466,6 +1466,10 @@ static int __net_init sctp_ctrlsock_init(struct net *net)
> >       if (status)
> >               pr_err("Failed to initialize the SCTP control sock\n");
> >
> > +     status = sctp_udp_sock_start(net);
>
> This can be masking the previous error.
right, will add more logs in sctp_udp_sock_start().

>
> > +     if (status)
> > +             pr_err("Failed to initialize the SCTP udp tunneling sock\n");
>                                                  SCTP UDP
>
> > +
> >       return status;
> >  }
> >
>
> This is the last comment I had.
> Thanks Xin! Nice patches.
Thanks for checking so carefully!

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

* Re: [PATCH net-next 15/15] sctp: enable udp tunneling socks
  2020-10-03  8:20                                 ` Xin Long
@ 2020-10-03  8:20                                   ` Xin Long
  0 siblings, 0 replies; 82+ messages in thread
From: Xin Long @ 2020-10-03  8:20 UTC (permalink / raw)
  To: Marcelo Ricardo Leitner
  Cc: network dev, linux-sctp, Neil Horman, Michael Tuexen, Tom Herbert, davem

On Sat, Oct 3, 2020 at 12:12 PM Marcelo Ricardo Leitner
<marcelo.leitner@gmail.com> wrote:
>
> On Tue, Sep 29, 2020 at 09:49:07PM +0800, Xin Long wrote:
> > This patch is to enable udp tunneling socks by calling
> > sctp_udp_sock_start() in sctp_ctrlsock_init(), and
> > sctp_udp_sock_stop() in sctp_ctrlsock_exit().
> >
> > Also add sysctl udp_port to allow changing the listening
> > sock's port by users.
> >
> > Wit this patch, the whole sctp over udp feature can be
>   With
>
> > enabled and used.
> ...
> > @@ -1466,6 +1466,10 @@ static int __net_init sctp_ctrlsock_init(struct net *net)
> >       if (status)
> >               pr_err("Failed to initialize the SCTP control sock\n");
> >
> > +     status = sctp_udp_sock_start(net);
>
> This can be masking the previous error.
right, will add more logs in sctp_udp_sock_start().

>
> > +     if (status)
> > +             pr_err("Failed to initialize the SCTP udp tunneling sock\n");
>                                                  SCTP UDP
>
> > +
> >       return status;
> >  }
> >
>
> This is the last comment I had.
> Thanks Xin! Nice patches.
Thanks for checking so carefully!

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

* Re: [PATCH net-next 11/15] sctp: add udphdr to overhead when udp_port is set
  2020-10-03  7:57                           ` Xin Long
  2020-10-03  8:12                             ` Xin Long
@ 2020-10-03 11:23                             ` Xin Long
  2020-10-03 11:23                               ` Xin Long
  2020-10-03 12:24                               ` Xin Long
  1 sibling, 2 replies; 82+ messages in thread
From: Xin Long @ 2020-10-03 11:23 UTC (permalink / raw)
  To: Marcelo Ricardo Leitner
  Cc: kernel test robot, network dev, linux-sctp, kbuild-all,
	Neil Horman, Michael Tuexen, davem

On Sat, Oct 3, 2020 at 4:12 PM Xin Long <lucien.xin@gmail.com> wrote:
>
> On Sat, Oct 3, 2020 at 12:08 PM Marcelo Ricardo Leitner
> <marcelo.leitner@gmail.com> wrote:
> >
> > On Wed, Sep 30, 2020 at 03:00:42AM +0800, kernel test robot wrote:
> > > Hi Xin,
> > >
> > > Thank you for the patch! Yet something to improve:
> >
> > I wonder how are you planning to fix this. It is quite entangled.
> > This is not performance critical. Maybe the cleanest way out is to
> > move it to a .c file.
> >
> > Adding a
> > #if defined(CONFIG_IP_SCTP) || defined(CONFIG_IP_SCTP_MODULE)
> > in there doesn't seem good.
> >
> > >    In file included from include/net/sctp/checksum.h:27,
> > >                     from net/netfilter/nf_nat_proto.c:16:
> > >    include/net/sctp/sctp.h: In function 'sctp_mtu_payload':
> > > >> include/net/sctp/sctp.h:583:31: error: 'struct net' has no member named 'sctp'; did you mean 'ct'?
> > >      583 |   if (sock_net(&sp->inet.sk)->sctp.udp_port)
> > >          |                               ^~~~
> > >          |                               ct
> > >
> Here is actually another problem, I'm still thinking how to fix it.
>
> Now sctp_mtu_payload() returns different value depending on
> net->sctp.udp_port. but net->sctp.udp_port can be changed by
> "sysctl -w" anytime. so:
>
> In sctp_packet_config() it gets overhead/headroom by calling
> sctp_mtu_payload(). When 'udp_port' is 0, it's IP+MAC header
> size. Then if 'udp_port' is changed to 9899 by 'sysctl -w',
> udphdr will also be added to the packet in sctp_v4_xmit(),
> and later the headroom may not be enough for IP+MAC headers.
>
> I'm thinking to add sctp_sock->udp_port, and it'll be set when
> the sock is created with net->udp_port. but not sure if we should
> update sctp_sock->udp_port with  net->udp_port when sending packets?
something like:

diff --git a/net/sctp/output.c b/net/sctp/output.c
index 6614c9fdc51e..c379d805b9df 100644
--- a/net/sctp/output.c
+++ b/net/sctp/output.c
@@ -91,6 +91,7 @@ void sctp_packet_config(struct sctp_packet *packet,
__u32 vtag,
        if (asoc) {
                sk = asoc->base.sk;
                sp = sctp_sk(sk);
+               sctp_sock_check_udp_port(sock_net(sk), sp, asoc);
        }
        packet->overhead = sctp_mtu_payload(sp, 0, 0);
        packet->size = packet->overhead;
diff --git a/net/sctp/sm_make_chunk.c b/net/sctp/sm_make_chunk.c
index 21d0ff1c6ab9..f5aba9086d33 100644
--- a/net/sctp/sm_make_chunk.c
+++ b/net/sctp/sm_make_chunk.c
@@ -1250,6 +1250,7 @@ static inline struct sctp_chunk
*sctp_make_op_error_limited(
        if (asoc) {
                size = min_t(size_t, size, asoc->pathmtu);
                sp = sctp_sk(asoc->base.sk);
+               sctp_sock_check_udp_port(sock_net(sk), sp, asoc);
        }

        size = sctp_mtu_payload(sp, size, sizeof(struct sctp_errhdr));
diff --git a/net/sctp/sm_statefuns.c b/net/sctp/sm_statefuns.c
index 8edab1533057..3e7f81d63d2e 100644
--- a/net/sctp/sm_statefuns.c
+++ b/net/sctp/sm_statefuns.c
@@ -6276,6 +6276,8 @@ static struct sctp_packet *sctp_ootb_pkt_new(
        sctp_transport_route(transport, (union sctp_addr *)&chunk->dest,
                             sctp_sk(net->sctp.ctl_sock));

+       sctp_sock_check_udp_port(net, net->sctp.ctl_sock, NULL);
+
        packet = &transport->packet;
        sctp_packet_init(packet, transport, sport, dport);
        sctp_packet_config(packet, vtag, 0);
diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index d793dfa94682..e5de5f98be0c 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -1550,6 +1550,17 @@ static int sctp_error(struct sock *sk, int
flags, int err)
        return err;
 }

+void sctp_sock_check_udp_port(struct net* net, struct sctp_sock *sp,
+                             struct sctp_association *asoc)
+{
+       if (likely(sp->udp_port = net->sctp.udp_port))
+               return;
+
+       if (asoc && (!sp->udp_port || !net->sctp.udp_port))
+               sctp_assoc_update_frag_point(asoc);
+       sp->udp_port = net->sctp.udp_port;
+}
+
 /* API 3.1.3 sendmsg() - UDP Style Syntax
  *
  * An application uses sendmsg() and recvmsg() calls to transmit data to
@@ -1795,6 +1806,8 @@ static int sctp_sendmsg_to_asoc(struct
sctp_association *asoc,
                        goto err;
        }

+       sctp_sock_check_udp_port(net, sp, asoc);
+
        if (sp->disable_fragments && msg_len > asoc->frag_point) {
                err = -EMSGSIZE;
                goto err;

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

* Re: [PATCH net-next 11/15] sctp: add udphdr to overhead when udp_port is set
  2020-10-03 11:23                             ` Xin Long
@ 2020-10-03 11:23                               ` Xin Long
  2020-10-03 12:24                               ` Xin Long
  1 sibling, 0 replies; 82+ messages in thread
From: Xin Long @ 2020-10-03 11:23 UTC (permalink / raw)
  To: Marcelo Ricardo Leitner
  Cc: kernel test robot, network dev, linux-sctp, kbuild-all,
	Neil Horman, Michael Tuexen, davem

On Sat, Oct 3, 2020 at 4:12 PM Xin Long <lucien.xin@gmail.com> wrote:
>
> On Sat, Oct 3, 2020 at 12:08 PM Marcelo Ricardo Leitner
> <marcelo.leitner@gmail.com> wrote:
> >
> > On Wed, Sep 30, 2020 at 03:00:42AM +0800, kernel test robot wrote:
> > > Hi Xin,
> > >
> > > Thank you for the patch! Yet something to improve:
> >
> > I wonder how are you planning to fix this. It is quite entangled.
> > This is not performance critical. Maybe the cleanest way out is to
> > move it to a .c file.
> >
> > Adding a
> > #if defined(CONFIG_IP_SCTP) || defined(CONFIG_IP_SCTP_MODULE)
> > in there doesn't seem good.
> >
> > >    In file included from include/net/sctp/checksum.h:27,
> > >                     from net/netfilter/nf_nat_proto.c:16:
> > >    include/net/sctp/sctp.h: In function 'sctp_mtu_payload':
> > > >> include/net/sctp/sctp.h:583:31: error: 'struct net' has no member named 'sctp'; did you mean 'ct'?
> > >      583 |   if (sock_net(&sp->inet.sk)->sctp.udp_port)
> > >          |                               ^~~~
> > >          |                               ct
> > >
> Here is actually another problem, I'm still thinking how to fix it.
>
> Now sctp_mtu_payload() returns different value depending on
> net->sctp.udp_port. but net->sctp.udp_port can be changed by
> "sysctl -w" anytime. so:
>
> In sctp_packet_config() it gets overhead/headroom by calling
> sctp_mtu_payload(). When 'udp_port' is 0, it's IP+MAC header
> size. Then if 'udp_port' is changed to 9899 by 'sysctl -w',
> udphdr will also be added to the packet in sctp_v4_xmit(),
> and later the headroom may not be enough for IP+MAC headers.
>
> I'm thinking to add sctp_sock->udp_port, and it'll be set when
> the sock is created with net->udp_port. but not sure if we should
> update sctp_sock->udp_port with  net->udp_port when sending packets?
something like:

diff --git a/net/sctp/output.c b/net/sctp/output.c
index 6614c9fdc51e..c379d805b9df 100644
--- a/net/sctp/output.c
+++ b/net/sctp/output.c
@@ -91,6 +91,7 @@ void sctp_packet_config(struct sctp_packet *packet,
__u32 vtag,
        if (asoc) {
                sk = asoc->base.sk;
                sp = sctp_sk(sk);
+               sctp_sock_check_udp_port(sock_net(sk), sp, asoc);
        }
        packet->overhead = sctp_mtu_payload(sp, 0, 0);
        packet->size = packet->overhead;
diff --git a/net/sctp/sm_make_chunk.c b/net/sctp/sm_make_chunk.c
index 21d0ff1c6ab9..f5aba9086d33 100644
--- a/net/sctp/sm_make_chunk.c
+++ b/net/sctp/sm_make_chunk.c
@@ -1250,6 +1250,7 @@ static inline struct sctp_chunk
*sctp_make_op_error_limited(
        if (asoc) {
                size = min_t(size_t, size, asoc->pathmtu);
                sp = sctp_sk(asoc->base.sk);
+               sctp_sock_check_udp_port(sock_net(sk), sp, asoc);
        }

        size = sctp_mtu_payload(sp, size, sizeof(struct sctp_errhdr));
diff --git a/net/sctp/sm_statefuns.c b/net/sctp/sm_statefuns.c
index 8edab1533057..3e7f81d63d2e 100644
--- a/net/sctp/sm_statefuns.c
+++ b/net/sctp/sm_statefuns.c
@@ -6276,6 +6276,8 @@ static struct sctp_packet *sctp_ootb_pkt_new(
        sctp_transport_route(transport, (union sctp_addr *)&chunk->dest,
                             sctp_sk(net->sctp.ctl_sock));

+       sctp_sock_check_udp_port(net, net->sctp.ctl_sock, NULL);
+
        packet = &transport->packet;
        sctp_packet_init(packet, transport, sport, dport);
        sctp_packet_config(packet, vtag, 0);
diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index d793dfa94682..e5de5f98be0c 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -1550,6 +1550,17 @@ static int sctp_error(struct sock *sk, int
flags, int err)
        return err;
 }

+void sctp_sock_check_udp_port(struct net* net, struct sctp_sock *sp,
+                             struct sctp_association *asoc)
+{
+       if (likely(sp->udp_port == net->sctp.udp_port))
+               return;
+
+       if (asoc && (!sp->udp_port || !net->sctp.udp_port))
+               sctp_assoc_update_frag_point(asoc);
+       sp->udp_port = net->sctp.udp_port;
+}
+
 /* API 3.1.3 sendmsg() - UDP Style Syntax
  *
  * An application uses sendmsg() and recvmsg() calls to transmit data to
@@ -1795,6 +1806,8 @@ static int sctp_sendmsg_to_asoc(struct
sctp_association *asoc,
                        goto err;
        }

+       sctp_sock_check_udp_port(net, sp, asoc);
+
        if (sp->disable_fragments && msg_len > asoc->frag_point) {
                err = -EMSGSIZE;
                goto err;

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

* Re: [PATCH net-next 11/15] sctp: add udphdr to overhead when udp_port is set
  2020-10-03 11:23                             ` Xin Long
  2020-10-03 11:23                               ` Xin Long
@ 2020-10-03 12:24                               ` Xin Long
  2020-10-03 12:24                                 ` Xin Long
  2020-10-05 19:01                                 ` Marcelo Ricardo Leitner
  1 sibling, 2 replies; 82+ messages in thread
From: Xin Long @ 2020-10-03 12:24 UTC (permalink / raw)
  To: Marcelo Ricardo Leitner
  Cc: kernel test robot, network dev, linux-sctp, kbuild-all,
	Neil Horman, Michael Tuexen, davem

On Sat, Oct 3, 2020 at 7:23 PM Xin Long <lucien.xin@gmail.com> wrote:
>
> On Sat, Oct 3, 2020 at 4:12 PM Xin Long <lucien.xin@gmail.com> wrote:
> >
> > On Sat, Oct 3, 2020 at 12:08 PM Marcelo Ricardo Leitner
> > <marcelo.leitner@gmail.com> wrote:
> > >
> > > On Wed, Sep 30, 2020 at 03:00:42AM +0800, kernel test robot wrote:
> > > > Hi Xin,
> > > >
> > > > Thank you for the patch! Yet something to improve:
> > >
> > > I wonder how are you planning to fix this. It is quite entangled.
> > > This is not performance critical. Maybe the cleanest way out is to
> > > move it to a .c file.
> > >
> > > Adding a
> > > #if defined(CONFIG_IP_SCTP) || defined(CONFIG_IP_SCTP_MODULE)
> > > in there doesn't seem good.
> > >
> > > >    In file included from include/net/sctp/checksum.h:27,
> > > >                     from net/netfilter/nf_nat_proto.c:16:
> > > >    include/net/sctp/sctp.h: In function 'sctp_mtu_payload':
> > > > >> include/net/sctp/sctp.h:583:31: error: 'struct net' has no member named 'sctp'; did you mean 'ct'?
> > > >      583 |   if (sock_net(&sp->inet.sk)->sctp.udp_port)
> > > >          |                               ^~~~
> > > >          |                               ct
> > > >
> > Here is actually another problem, I'm still thinking how to fix it.
> >
> > Now sctp_mtu_payload() returns different value depending on
> > net->sctp.udp_port. but net->sctp.udp_port can be changed by
> > "sysctl -w" anytime. so:
> >
> > In sctp_packet_config() it gets overhead/headroom by calling
> > sctp_mtu_payload(). When 'udp_port' is 0, it's IP+MAC header
> > size. Then if 'udp_port' is changed to 9899 by 'sysctl -w',
> > udphdr will also be added to the packet in sctp_v4_xmit(),
> > and later the headroom may not be enough for IP+MAC headers.
> >
> > I'm thinking to add sctp_sock->udp_port, and it'll be set when
> > the sock is created with net->udp_port. but not sure if we should
> > update sctp_sock->udp_port with  net->udp_port when sending packets?
> something like:
>
> diff --git a/net/sctp/output.c b/net/sctp/output.c
> index 6614c9fdc51e..c379d805b9df 100644
> --- a/net/sctp/output.c
> +++ b/net/sctp/output.c
> @@ -91,6 +91,7 @@ void sctp_packet_config(struct sctp_packet *packet,
> __u32 vtag,
>         if (asoc) {
>                 sk = asoc->base.sk;
>                 sp = sctp_sk(sk);
> +               sctp_sock_check_udp_port(sock_net(sk), sp, asoc);
>         }
>         packet->overhead = sctp_mtu_payload(sp, 0, 0);
>         packet->size = packet->overhead;
> diff --git a/net/sctp/sm_make_chunk.c b/net/sctp/sm_make_chunk.c
> index 21d0ff1c6ab9..f5aba9086d33 100644
> --- a/net/sctp/sm_make_chunk.c
> +++ b/net/sctp/sm_make_chunk.c
> @@ -1250,6 +1250,7 @@ static inline struct sctp_chunk
> *sctp_make_op_error_limited(
>         if (asoc) {
>                 size = min_t(size_t, size, asoc->pathmtu);
>                 sp = sctp_sk(asoc->base.sk);
> +               sctp_sock_check_udp_port(sock_net(sk), sp, asoc);
>         }
>
>         size = sctp_mtu_payload(sp, size, sizeof(struct sctp_errhdr));
> diff --git a/net/sctp/sm_statefuns.c b/net/sctp/sm_statefuns.c
> index 8edab1533057..3e7f81d63d2e 100644
> --- a/net/sctp/sm_statefuns.c
> +++ b/net/sctp/sm_statefuns.c
> @@ -6276,6 +6276,8 @@ static struct sctp_packet *sctp_ootb_pkt_new(
>         sctp_transport_route(transport, (union sctp_addr *)&chunk->dest,
>                              sctp_sk(net->sctp.ctl_sock));
>
> +       sctp_sock_check_udp_port(net, net->sctp.ctl_sock, NULL);
> +
>         packet = &transport->packet;
>         sctp_packet_init(packet, transport, sport, dport);
>         sctp_packet_config(packet, vtag, 0);
> diff --git a/net/sctp/socket.c b/net/sctp/socket.c
> index d793dfa94682..e5de5f98be0c 100644
> --- a/net/sctp/socket.c
> +++ b/net/sctp/socket.c
> @@ -1550,6 +1550,17 @@ static int sctp_error(struct sock *sk, int
> flags, int err)
>         return err;
>  }
>
> +void sctp_sock_check_udp_port(struct net* net, struct sctp_sock *sp,
> +                             struct sctp_association *asoc)
> +{
> +       if (likely(sp->udp_port = net->sctp.udp_port))
> +               return;
> +
> +       if (asoc && (!sp->udp_port || !net->sctp.udp_port))
> +               sctp_assoc_update_frag_point(asoc);
> +       sp->udp_port = net->sctp.udp_port;
> +}
> +
>  /* API 3.1.3 sendmsg() - UDP Style Syntax
>   *
>   * An application uses sendmsg() and recvmsg() calls to transmit data to
> @@ -1795,6 +1806,8 @@ static int sctp_sendmsg_to_asoc(struct
> sctp_association *asoc,
>                         goto err;
>         }
>
> +       sctp_sock_check_udp_port(net, sp, asoc);
> +
>         if (sp->disable_fragments && msg_len > asoc->frag_point) {
>                 err = -EMSGSIZE;
>                 goto err;

diff --git a/include/net/sctp/sctp.h b/include/net/sctp/sctp.h
index 6408bbb1b95d..86f74f2fe6de 100644
--- a/include/net/sctp/sctp.h
+++ b/include/net/sctp/sctp.h
@@ -580,7 +580,7 @@ static inline __u32 sctp_mtu_payload(const struct
sctp_sock *sp,

        if (sp) {
                overhead += sp->pf->af->net_header_len;
-               if (sock_net(&sp->inet.sk)->sctp.udp_port)
+               if (sp->udp_port)
                        overhead += sizeof(struct udphdr);
        } else {
                overhead += sizeof(struct ipv6hdr);
diff --git a/net/sctp/output.c b/net/sctp/output.c
index 6614c9fdc51e..c96b13ec72f4 100644
--- a/net/sctp/output.c
+++ b/net/sctp/output.c
@@ -91,6 +91,14 @@ void sctp_packet_config(struct sctp_packet *packet,
__u32 vtag,
        if (asoc) {
                sk = asoc->base.sk;
                sp = sctp_sk(sk);
+
+               if (unlikely(sp->udp_port != sock_net(sk)->sctp.udp_port)) {
+                       __u16 port = sock_net(sk)->sctp.udp_port;
+
+                       if (!sp->udp_port || !port)
+                               sctp_assoc_update_frag_point(asoc);
+                       sp->udp_port = port;
+               }
        }
diff --git a/net/sctp/sm_statefuns.c b/net/sctp/sm_statefuns.c
index 8edab1533057..8deb9d1554e9 100644
--- a/net/sctp/sm_statefuns.c
+++ b/net/sctp/sm_statefuns.c
@@ -6276,6 +6276,8 @@ static struct sctp_packet *sctp_ootb_pkt_new(
        sctp_transport_route(transport, (union sctp_addr *)&chunk->dest,
                             sctp_sk(net->sctp.ctl_sock));

+       sctp_sk(net->sctp.ctl_sock)->udp_port = net->sctp.udp_port;
+
        packet = &transport->packet;
        sctp_packet_init(packet, transport, sport, dport);
        sctp_packet_config(packet, vtag, 0);

Actually doing this is enough, more simple and clear.

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

* Re: [PATCH net-next 11/15] sctp: add udphdr to overhead when udp_port is set
  2020-10-03 12:24                               ` Xin Long
@ 2020-10-03 12:24                                 ` Xin Long
  2020-10-05 19:01                                 ` Marcelo Ricardo Leitner
  1 sibling, 0 replies; 82+ messages in thread
From: Xin Long @ 2020-10-03 12:24 UTC (permalink / raw)
  To: Marcelo Ricardo Leitner
  Cc: kernel test robot, network dev, linux-sctp, kbuild-all,
	Neil Horman, Michael Tuexen, davem

On Sat, Oct 3, 2020 at 7:23 PM Xin Long <lucien.xin@gmail.com> wrote:
>
> On Sat, Oct 3, 2020 at 4:12 PM Xin Long <lucien.xin@gmail.com> wrote:
> >
> > On Sat, Oct 3, 2020 at 12:08 PM Marcelo Ricardo Leitner
> > <marcelo.leitner@gmail.com> wrote:
> > >
> > > On Wed, Sep 30, 2020 at 03:00:42AM +0800, kernel test robot wrote:
> > > > Hi Xin,
> > > >
> > > > Thank you for the patch! Yet something to improve:
> > >
> > > I wonder how are you planning to fix this. It is quite entangled.
> > > This is not performance critical. Maybe the cleanest way out is to
> > > move it to a .c file.
> > >
> > > Adding a
> > > #if defined(CONFIG_IP_SCTP) || defined(CONFIG_IP_SCTP_MODULE)
> > > in there doesn't seem good.
> > >
> > > >    In file included from include/net/sctp/checksum.h:27,
> > > >                     from net/netfilter/nf_nat_proto.c:16:
> > > >    include/net/sctp/sctp.h: In function 'sctp_mtu_payload':
> > > > >> include/net/sctp/sctp.h:583:31: error: 'struct net' has no member named 'sctp'; did you mean 'ct'?
> > > >      583 |   if (sock_net(&sp->inet.sk)->sctp.udp_port)
> > > >          |                               ^~~~
> > > >          |                               ct
> > > >
> > Here is actually another problem, I'm still thinking how to fix it.
> >
> > Now sctp_mtu_payload() returns different value depending on
> > net->sctp.udp_port. but net->sctp.udp_port can be changed by
> > "sysctl -w" anytime. so:
> >
> > In sctp_packet_config() it gets overhead/headroom by calling
> > sctp_mtu_payload(). When 'udp_port' is 0, it's IP+MAC header
> > size. Then if 'udp_port' is changed to 9899 by 'sysctl -w',
> > udphdr will also be added to the packet in sctp_v4_xmit(),
> > and later the headroom may not be enough for IP+MAC headers.
> >
> > I'm thinking to add sctp_sock->udp_port, and it'll be set when
> > the sock is created with net->udp_port. but not sure if we should
> > update sctp_sock->udp_port with  net->udp_port when sending packets?
> something like:
>
> diff --git a/net/sctp/output.c b/net/sctp/output.c
> index 6614c9fdc51e..c379d805b9df 100644
> --- a/net/sctp/output.c
> +++ b/net/sctp/output.c
> @@ -91,6 +91,7 @@ void sctp_packet_config(struct sctp_packet *packet,
> __u32 vtag,
>         if (asoc) {
>                 sk = asoc->base.sk;
>                 sp = sctp_sk(sk);
> +               sctp_sock_check_udp_port(sock_net(sk), sp, asoc);
>         }
>         packet->overhead = sctp_mtu_payload(sp, 0, 0);
>         packet->size = packet->overhead;
> diff --git a/net/sctp/sm_make_chunk.c b/net/sctp/sm_make_chunk.c
> index 21d0ff1c6ab9..f5aba9086d33 100644
> --- a/net/sctp/sm_make_chunk.c
> +++ b/net/sctp/sm_make_chunk.c
> @@ -1250,6 +1250,7 @@ static inline struct sctp_chunk
> *sctp_make_op_error_limited(
>         if (asoc) {
>                 size = min_t(size_t, size, asoc->pathmtu);
>                 sp = sctp_sk(asoc->base.sk);
> +               sctp_sock_check_udp_port(sock_net(sk), sp, asoc);
>         }
>
>         size = sctp_mtu_payload(sp, size, sizeof(struct sctp_errhdr));
> diff --git a/net/sctp/sm_statefuns.c b/net/sctp/sm_statefuns.c
> index 8edab1533057..3e7f81d63d2e 100644
> --- a/net/sctp/sm_statefuns.c
> +++ b/net/sctp/sm_statefuns.c
> @@ -6276,6 +6276,8 @@ static struct sctp_packet *sctp_ootb_pkt_new(
>         sctp_transport_route(transport, (union sctp_addr *)&chunk->dest,
>                              sctp_sk(net->sctp.ctl_sock));
>
> +       sctp_sock_check_udp_port(net, net->sctp.ctl_sock, NULL);
> +
>         packet = &transport->packet;
>         sctp_packet_init(packet, transport, sport, dport);
>         sctp_packet_config(packet, vtag, 0);
> diff --git a/net/sctp/socket.c b/net/sctp/socket.c
> index d793dfa94682..e5de5f98be0c 100644
> --- a/net/sctp/socket.c
> +++ b/net/sctp/socket.c
> @@ -1550,6 +1550,17 @@ static int sctp_error(struct sock *sk, int
> flags, int err)
>         return err;
>  }
>
> +void sctp_sock_check_udp_port(struct net* net, struct sctp_sock *sp,
> +                             struct sctp_association *asoc)
> +{
> +       if (likely(sp->udp_port == net->sctp.udp_port))
> +               return;
> +
> +       if (asoc && (!sp->udp_port || !net->sctp.udp_port))
> +               sctp_assoc_update_frag_point(asoc);
> +       sp->udp_port = net->sctp.udp_port;
> +}
> +
>  /* API 3.1.3 sendmsg() - UDP Style Syntax
>   *
>   * An application uses sendmsg() and recvmsg() calls to transmit data to
> @@ -1795,6 +1806,8 @@ static int sctp_sendmsg_to_asoc(struct
> sctp_association *asoc,
>                         goto err;
>         }
>
> +       sctp_sock_check_udp_port(net, sp, asoc);
> +
>         if (sp->disable_fragments && msg_len > asoc->frag_point) {
>                 err = -EMSGSIZE;
>                 goto err;

diff --git a/include/net/sctp/sctp.h b/include/net/sctp/sctp.h
index 6408bbb1b95d..86f74f2fe6de 100644
--- a/include/net/sctp/sctp.h
+++ b/include/net/sctp/sctp.h
@@ -580,7 +580,7 @@ static inline __u32 sctp_mtu_payload(const struct
sctp_sock *sp,

        if (sp) {
                overhead += sp->pf->af->net_header_len;
-               if (sock_net(&sp->inet.sk)->sctp.udp_port)
+               if (sp->udp_port)
                        overhead += sizeof(struct udphdr);
        } else {
                overhead += sizeof(struct ipv6hdr);
diff --git a/net/sctp/output.c b/net/sctp/output.c
index 6614c9fdc51e..c96b13ec72f4 100644
--- a/net/sctp/output.c
+++ b/net/sctp/output.c
@@ -91,6 +91,14 @@ void sctp_packet_config(struct sctp_packet *packet,
__u32 vtag,
        if (asoc) {
                sk = asoc->base.sk;
                sp = sctp_sk(sk);
+
+               if (unlikely(sp->udp_port != sock_net(sk)->sctp.udp_port)) {
+                       __u16 port = sock_net(sk)->sctp.udp_port;
+
+                       if (!sp->udp_port || !port)
+                               sctp_assoc_update_frag_point(asoc);
+                       sp->udp_port = port;
+               }
        }
diff --git a/net/sctp/sm_statefuns.c b/net/sctp/sm_statefuns.c
index 8edab1533057..8deb9d1554e9 100644
--- a/net/sctp/sm_statefuns.c
+++ b/net/sctp/sm_statefuns.c
@@ -6276,6 +6276,8 @@ static struct sctp_packet *sctp_ootb_pkt_new(
        sctp_transport_route(transport, (union sctp_addr *)&chunk->dest,
                             sctp_sk(net->sctp.ctl_sock));

+       sctp_sk(net->sctp.ctl_sock)->udp_port = net->sctp.udp_port;
+
        packet = &transport->packet;
        sctp_packet_init(packet, transport, sport, dport);
        sctp_packet_config(packet, vtag, 0);

Actually doing this is enough, more simple and clear.

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

* Re: [PATCH net-next 11/15] sctp: add udphdr to overhead when udp_port is set
  2020-10-03 12:24                               ` Xin Long
  2020-10-03 12:24                                 ` Xin Long
@ 2020-10-05 19:01                                 ` Marcelo Ricardo Leitner
  2020-10-05 19:01                                   ` Marcelo Ricardo Leitner
                                                     ` (2 more replies)
  1 sibling, 3 replies; 82+ messages in thread
From: Marcelo Ricardo Leitner @ 2020-10-05 19:01 UTC (permalink / raw)
  To: Xin Long
  Cc: kernel test robot, network dev, linux-sctp, kbuild-all,
	Neil Horman, Michael Tuexen, davem

On Sat, Oct 03, 2020 at 08:24:34PM +0800, Xin Long wrote:
> On Sat, Oct 3, 2020 at 7:23 PM Xin Long <lucien.xin@gmail.com> wrote:
> >
> > On Sat, Oct 3, 2020 at 4:12 PM Xin Long <lucien.xin@gmail.com> wrote:
> > >
> > > On Sat, Oct 3, 2020 at 12:08 PM Marcelo Ricardo Leitner
> > > <marcelo.leitner@gmail.com> wrote:
> > > >
> > > > On Wed, Sep 30, 2020 at 03:00:42AM +0800, kernel test robot wrote:
> > > > > Hi Xin,
> > > > >
> > > > > Thank you for the patch! Yet something to improve:
> > > >
> > > > I wonder how are you planning to fix this. It is quite entangled.
> > > > This is not performance critical. Maybe the cleanest way out is to
> > > > move it to a .c file.
> > > >
> > > > Adding a
> > > > #if defined(CONFIG_IP_SCTP) || defined(CONFIG_IP_SCTP_MODULE)
> > > > in there doesn't seem good.
> > > >
> > > > >    In file included from include/net/sctp/checksum.h:27,
> > > > >                     from net/netfilter/nf_nat_proto.c:16:
> > > > >    include/net/sctp/sctp.h: In function 'sctp_mtu_payload':
> > > > > >> include/net/sctp/sctp.h:583:31: error: 'struct net' has no member named 'sctp'; did you mean 'ct'?
> > > > >      583 |   if (sock_net(&sp->inet.sk)->sctp.udp_port)
> > > > >          |                               ^~~~
> > > > >          |                               ct
> > > > >
> > > Here is actually another problem, I'm still thinking how to fix it.
> > >
> > > Now sctp_mtu_payload() returns different value depending on
> > > net->sctp.udp_port. but net->sctp.udp_port can be changed by
> > > "sysctl -w" anytime. so:

Good point.

> > >
> > > In sctp_packet_config() it gets overhead/headroom by calling
> > > sctp_mtu_payload(). When 'udp_port' is 0, it's IP+MAC header
> > > size. Then if 'udp_port' is changed to 9899 by 'sysctl -w',
> > > udphdr will also be added to the packet in sctp_v4_xmit(),
> > > and later the headroom may not be enough for IP+MAC headers.
> > >
> > > I'm thinking to add sctp_sock->udp_port, and it'll be set when
> > > the sock is created with net->udp_port. but not sure if we should
> > > update sctp_sock->udp_port with  net->udp_port when sending packets?

I don't think so,

> > something like:
...
> diff --git a/net/sctp/output.c b/net/sctp/output.c
> index 6614c9fdc51e..c96b13ec72f4 100644
> --- a/net/sctp/output.c
> +++ b/net/sctp/output.c
> @@ -91,6 +91,14 @@ void sctp_packet_config(struct sctp_packet *packet,
> __u32 vtag,
>         if (asoc) {
>                 sk = asoc->base.sk;
>                 sp = sctp_sk(sk);
> +
> +               if (unlikely(sp->udp_port != sock_net(sk)->sctp.udp_port)) {

RFC6951 has:

6.1.  Get or Set the Remote UDP Encapsulation Port Number
      (SCTP_REMOTE_UDP_ENCAPS_PORT)
...
   sue_assoc_id:  This parameter is ignored for one-to-one style
      sockets.  For one-to-many style sockets, the application may fill
      in an association identifier or SCTP_FUTURE_ASSOC for this query.
      It is an error to use SCTP_{CURRENT|ALL}_ASSOC in sue_assoc_id.

   sue_address:  This specifies which address is of interest.  If a
      wildcard address is provided, it applies only to future paths.

So I'm not seeing a reason to have a system wide knob that takes
effect in run time like this.
Enable, start apps, and they keep behaving as initially configured.
Need to disable? Restart the apps/sockets.

Thoughts?

> +                       __u16 port = sock_net(sk)->sctp.udp_port;
> +
> +                       if (!sp->udp_port || !port)
> +                               sctp_assoc_update_frag_point(asoc);
> +                       sp->udp_port = port;
> +               }
>         }

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

* Re: [PATCH net-next 11/15] sctp: add udphdr to overhead when udp_port is set
  2020-10-05 19:01                                 ` Marcelo Ricardo Leitner
@ 2020-10-05 19:01                                   ` Marcelo Ricardo Leitner
  2020-10-05 20:08                                   ` Michael Tuexen
  2020-10-08  9:37                                   ` Xin Long
  2 siblings, 0 replies; 82+ messages in thread
From: Marcelo Ricardo Leitner @ 2020-10-05 19:01 UTC (permalink / raw)
  To: Xin Long
  Cc: kernel test robot, network dev, linux-sctp, kbuild-all,
	Neil Horman, Michael Tuexen, davem

On Sat, Oct 03, 2020 at 08:24:34PM +0800, Xin Long wrote:
> On Sat, Oct 3, 2020 at 7:23 PM Xin Long <lucien.xin@gmail.com> wrote:
> >
> > On Sat, Oct 3, 2020 at 4:12 PM Xin Long <lucien.xin@gmail.com> wrote:
> > >
> > > On Sat, Oct 3, 2020 at 12:08 PM Marcelo Ricardo Leitner
> > > <marcelo.leitner@gmail.com> wrote:
> > > >
> > > > On Wed, Sep 30, 2020 at 03:00:42AM +0800, kernel test robot wrote:
> > > > > Hi Xin,
> > > > >
> > > > > Thank you for the patch! Yet something to improve:
> > > >
> > > > I wonder how are you planning to fix this. It is quite entangled.
> > > > This is not performance critical. Maybe the cleanest way out is to
> > > > move it to a .c file.
> > > >
> > > > Adding a
> > > > #if defined(CONFIG_IP_SCTP) || defined(CONFIG_IP_SCTP_MODULE)
> > > > in there doesn't seem good.
> > > >
> > > > >    In file included from include/net/sctp/checksum.h:27,
> > > > >                     from net/netfilter/nf_nat_proto.c:16:
> > > > >    include/net/sctp/sctp.h: In function 'sctp_mtu_payload':
> > > > > >> include/net/sctp/sctp.h:583:31: error: 'struct net' has no member named 'sctp'; did you mean 'ct'?
> > > > >      583 |   if (sock_net(&sp->inet.sk)->sctp.udp_port)
> > > > >          |                               ^~~~
> > > > >          |                               ct
> > > > >
> > > Here is actually another problem, I'm still thinking how to fix it.
> > >
> > > Now sctp_mtu_payload() returns different value depending on
> > > net->sctp.udp_port. but net->sctp.udp_port can be changed by
> > > "sysctl -w" anytime. so:

Good point.

> > >
> > > In sctp_packet_config() it gets overhead/headroom by calling
> > > sctp_mtu_payload(). When 'udp_port' is 0, it's IP+MAC header
> > > size. Then if 'udp_port' is changed to 9899 by 'sysctl -w',
> > > udphdr will also be added to the packet in sctp_v4_xmit(),
> > > and later the headroom may not be enough for IP+MAC headers.
> > >
> > > I'm thinking to add sctp_sock->udp_port, and it'll be set when
> > > the sock is created with net->udp_port. but not sure if we should
> > > update sctp_sock->udp_port with  net->udp_port when sending packets?

I don't think so,

> > something like:
...
> diff --git a/net/sctp/output.c b/net/sctp/output.c
> index 6614c9fdc51e..c96b13ec72f4 100644
> --- a/net/sctp/output.c
> +++ b/net/sctp/output.c
> @@ -91,6 +91,14 @@ void sctp_packet_config(struct sctp_packet *packet,
> __u32 vtag,
>         if (asoc) {
>                 sk = asoc->base.sk;
>                 sp = sctp_sk(sk);
> +
> +               if (unlikely(sp->udp_port != sock_net(sk)->sctp.udp_port)) {

RFC6951 has:

6.1.  Get or Set the Remote UDP Encapsulation Port Number
      (SCTP_REMOTE_UDP_ENCAPS_PORT)
...
   sue_assoc_id:  This parameter is ignored for one-to-one style
      sockets.  For one-to-many style sockets, the application may fill
      in an association identifier or SCTP_FUTURE_ASSOC for this query.
      It is an error to use SCTP_{CURRENT|ALL}_ASSOC in sue_assoc_id.

   sue_address:  This specifies which address is of interest.  If a
      wildcard address is provided, it applies only to future paths.

So I'm not seeing a reason to have a system wide knob that takes
effect in run time like this.
Enable, start apps, and they keep behaving as initially configured.
Need to disable? Restart the apps/sockets.

Thoughts?

> +                       __u16 port = sock_net(sk)->sctp.udp_port;
> +
> +                       if (!sp->udp_port || !port)
> +                               sctp_assoc_update_frag_point(asoc);
> +                       sp->udp_port = port;
> +               }
>         }

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

* Re: [PATCH net-next 11/15] sctp: add udphdr to overhead when udp_port is set
  2020-10-05 19:01                                 ` Marcelo Ricardo Leitner
  2020-10-05 19:01                                   ` Marcelo Ricardo Leitner
@ 2020-10-05 20:08                                   ` Michael Tuexen
  2020-10-05 20:08                                     ` Michael Tuexen
  2020-10-08  9:37                                   ` Xin Long
  2 siblings, 1 reply; 82+ messages in thread
From: Michael Tuexen @ 2020-10-05 20:08 UTC (permalink / raw)
  To: Marcelo Ricardo Leitner
  Cc: Xin Long, kernel test robot, network dev, linux-sctp, kbuild-all,
	Neil Horman, davem

[-- Attachment #1: Type: text/plain, Size: 4647 bytes --]

> On 5. Oct 2020, at 21:01, Marcelo Ricardo Leitner <marcelo.leitner@gmail.com> wrote:
> 
> On Sat, Oct 03, 2020 at 08:24:34PM +0800, Xin Long wrote:
>> On Sat, Oct 3, 2020 at 7:23 PM Xin Long <lucien.xin@gmail.com> wrote:
>>> 
>>> On Sat, Oct 3, 2020 at 4:12 PM Xin Long <lucien.xin@gmail.com> wrote:
>>>> 
>>>> On Sat, Oct 3, 2020 at 12:08 PM Marcelo Ricardo Leitner
>>>> <marcelo.leitner@gmail.com> wrote:
>>>>> 
>>>>> On Wed, Sep 30, 2020 at 03:00:42AM +0800, kernel test robot wrote:
>>>>>> Hi Xin,
>>>>>> 
>>>>>> Thank you for the patch! Yet something to improve:
>>>>> 
>>>>> I wonder how are you planning to fix this. It is quite entangled.
>>>>> This is not performance critical. Maybe the cleanest way out is to
>>>>> move it to a .c file.
>>>>> 
>>>>> Adding a
>>>>> #if defined(CONFIG_IP_SCTP) || defined(CONFIG_IP_SCTP_MODULE)
>>>>> in there doesn't seem good.
>>>>> 
>>>>>>   In file included from include/net/sctp/checksum.h:27,
>>>>>>                    from net/netfilter/nf_nat_proto.c:16:
>>>>>>   include/net/sctp/sctp.h: In function 'sctp_mtu_payload':
>>>>>>>> include/net/sctp/sctp.h:583:31: error: 'struct net' has no member named 'sctp'; did you mean 'ct'?
>>>>>>     583 |   if (sock_net(&sp->inet.sk)->sctp.udp_port)
>>>>>>         |                               ^~~~
>>>>>>         |                               ct
>>>>>> 
>>>> Here is actually another problem, I'm still thinking how to fix it.
>>>> 
>>>> Now sctp_mtu_payload() returns different value depending on
>>>> net->sctp.udp_port. but net->sctp.udp_port can be changed by
>>>> "sysctl -w" anytime. so:
> 
> Good point.
> 
>>>> 
>>>> In sctp_packet_config() it gets overhead/headroom by calling
>>>> sctp_mtu_payload(). When 'udp_port' is 0, it's IP+MAC header
>>>> size. Then if 'udp_port' is changed to 9899 by 'sysctl -w',
>>>> udphdr will also be added to the packet in sctp_v4_xmit(),
>>>> and later the headroom may not be enough for IP+MAC headers.
>>>> 
>>>> I'm thinking to add sctp_sock->udp_port, and it'll be set when
>>>> the sock is created with net->udp_port. but not sure if we should
>>>> update sctp_sock->udp_port with  net->udp_port when sending packets?
> 
> I don't think so,
> 
>>> something like:
> ...
>> diff --git a/net/sctp/output.c b/net/sctp/output.c
>> index 6614c9fdc51e..c96b13ec72f4 100644
>> --- a/net/sctp/output.c
>> +++ b/net/sctp/output.c
>> @@ -91,6 +91,14 @@ void sctp_packet_config(struct sctp_packet *packet,
>> __u32 vtag,
>>        if (asoc) {
>>                sk = asoc->base.sk;
>>                sp = sctp_sk(sk);
>> +
>> +               if (unlikely(sp->udp_port != sock_net(sk)->sctp.udp_port)) {
> 
> RFC6951 has:
> 
> 6.1.  Get or Set the Remote UDP Encapsulation Port Number
>      (SCTP_REMOTE_UDP_ENCAPS_PORT)
> ...
>   sue_assoc_id:  This parameter is ignored for one-to-one style
>      sockets.  For one-to-many style sockets, the application may fill
>      in an association identifier or SCTP_FUTURE_ASSOC for this query.
>      It is an error to use SCTP_{CURRENT|ALL}_ASSOC in sue_assoc_id.
> 
>   sue_address:  This specifies which address is of interest.  If a
>      wildcard address is provided, it applies only to future paths.
> 
> So I'm not seeing a reason to have a system wide knob that takes
> effect in run time like this.
> Enable, start apps, and they keep behaving as initially configured.
> Need to disable? Restart the apps/sockets.
> 
> Thoughts?
Just note about how things are implemented in FreeBSD. This is not about
how it has to be implemented, but how it can be implemented.

The local UDP encaps port is controlled by a system wide sysctl.
sudo sysctl net.inet.sctp.udp_tunneling_port=9899
will use from that point on port 9899 the local encaps port. The
local encaps port can't be controlled by the application.
sudo sysctl net.inet.sctp.udp_tunneling_port=9900
will change this port number instantly to 9900. I don't see a
use case for this, but it is possible.
sudo sysctl net.inet.sctp.udp_tunneling_port=0
disables the sending and receiving of UDP encapsulated packets.

The application can only control the remote encapsulation port on
a per remote address base. This is mostly relevant for the client
side wanting to use UDP encapsulation.

Best regards
Michael
> 
>> +                       __u16 port = sock_net(sk)->sctp.udp_port;
>> +
>> +                       if (!sp->udp_port || !port)
>> +                               sctp_assoc_update_frag_point(asoc);
>> +                       sp->udp_port = port;
>> +               }
>>        }


[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5257 bytes --]

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

* Re: [PATCH net-next 11/15] sctp: add udphdr to overhead when udp_port is set
  2020-10-05 20:08                                   ` Michael Tuexen
@ 2020-10-05 20:08                                     ` Michael Tuexen
  0 siblings, 0 replies; 82+ messages in thread
From: Michael Tuexen @ 2020-10-05 20:08 UTC (permalink / raw)
  To: Marcelo Ricardo Leitner
  Cc: Xin Long, kernel test robot, network dev, linux-sctp, kbuild-all,
	Neil Horman, davem

[-- Attachment #1: Type: text/plain, Size: 4647 bytes --]

> On 5. Oct 2020, at 21:01, Marcelo Ricardo Leitner <marcelo.leitner@gmail.com> wrote:
> 
> On Sat, Oct 03, 2020 at 08:24:34PM +0800, Xin Long wrote:
>> On Sat, Oct 3, 2020 at 7:23 PM Xin Long <lucien.xin@gmail.com> wrote:
>>> 
>>> On Sat, Oct 3, 2020 at 4:12 PM Xin Long <lucien.xin@gmail.com> wrote:
>>>> 
>>>> On Sat, Oct 3, 2020 at 12:08 PM Marcelo Ricardo Leitner
>>>> <marcelo.leitner@gmail.com> wrote:
>>>>> 
>>>>> On Wed, Sep 30, 2020 at 03:00:42AM +0800, kernel test robot wrote:
>>>>>> Hi Xin,
>>>>>> 
>>>>>> Thank you for the patch! Yet something to improve:
>>>>> 
>>>>> I wonder how are you planning to fix this. It is quite entangled.
>>>>> This is not performance critical. Maybe the cleanest way out is to
>>>>> move it to a .c file.
>>>>> 
>>>>> Adding a
>>>>> #if defined(CONFIG_IP_SCTP) || defined(CONFIG_IP_SCTP_MODULE)
>>>>> in there doesn't seem good.
>>>>> 
>>>>>>   In file included from include/net/sctp/checksum.h:27,
>>>>>>                    from net/netfilter/nf_nat_proto.c:16:
>>>>>>   include/net/sctp/sctp.h: In function 'sctp_mtu_payload':
>>>>>>>> include/net/sctp/sctp.h:583:31: error: 'struct net' has no member named 'sctp'; did you mean 'ct'?
>>>>>>     583 |   if (sock_net(&sp->inet.sk)->sctp.udp_port)
>>>>>>         |                               ^~~~
>>>>>>         |                               ct
>>>>>> 
>>>> Here is actually another problem, I'm still thinking how to fix it.
>>>> 
>>>> Now sctp_mtu_payload() returns different value depending on
>>>> net->sctp.udp_port. but net->sctp.udp_port can be changed by
>>>> "sysctl -w" anytime. so:
> 
> Good point.
> 
>>>> 
>>>> In sctp_packet_config() it gets overhead/headroom by calling
>>>> sctp_mtu_payload(). When 'udp_port' is 0, it's IP+MAC header
>>>> size. Then if 'udp_port' is changed to 9899 by 'sysctl -w',
>>>> udphdr will also be added to the packet in sctp_v4_xmit(),
>>>> and later the headroom may not be enough for IP+MAC headers.
>>>> 
>>>> I'm thinking to add sctp_sock->udp_port, and it'll be set when
>>>> the sock is created with net->udp_port. but not sure if we should
>>>> update sctp_sock->udp_port with  net->udp_port when sending packets?
> 
> I don't think so,
> 
>>> something like:
> ...
>> diff --git a/net/sctp/output.c b/net/sctp/output.c
>> index 6614c9fdc51e..c96b13ec72f4 100644
>> --- a/net/sctp/output.c
>> +++ b/net/sctp/output.c
>> @@ -91,6 +91,14 @@ void sctp_packet_config(struct sctp_packet *packet,
>> __u32 vtag,
>>        if (asoc) {
>>                sk = asoc->base.sk;
>>                sp = sctp_sk(sk);
>> +
>> +               if (unlikely(sp->udp_port != sock_net(sk)->sctp.udp_port)) {
> 
> RFC6951 has:
> 
> 6.1.  Get or Set the Remote UDP Encapsulation Port Number
>      (SCTP_REMOTE_UDP_ENCAPS_PORT)
> ...
>   sue_assoc_id:  This parameter is ignored for one-to-one style
>      sockets.  For one-to-many style sockets, the application may fill
>      in an association identifier or SCTP_FUTURE_ASSOC for this query.
>      It is an error to use SCTP_{CURRENT|ALL}_ASSOC in sue_assoc_id.
> 
>   sue_address:  This specifies which address is of interest.  If a
>      wildcard address is provided, it applies only to future paths.
> 
> So I'm not seeing a reason to have a system wide knob that takes
> effect in run time like this.
> Enable, start apps, and they keep behaving as initially configured.
> Need to disable? Restart the apps/sockets.
> 
> Thoughts?
Just note about how things are implemented in FreeBSD. This is not about
how it has to be implemented, but how it can be implemented.

The local UDP encaps port is controlled by a system wide sysctl.
sudo sysctl net.inet.sctp.udp_tunneling_port=9899
will use from that point on port 9899 the local encaps port. The
local encaps port can't be controlled by the application.
sudo sysctl net.inet.sctp.udp_tunneling_port=9900
will change this port number instantly to 9900. I don't see a
use case for this, but it is possible.
sudo sysctl net.inet.sctp.udp_tunneling_port=0
disables the sending and receiving of UDP encapsulated packets.

The application can only control the remote encapsulation port on
a per remote address base. This is mostly relevant for the client
side wanting to use UDP encapsulation.

Best regards
Michael
> 
>> +                       __u16 port = sock_net(sk)->sctp.udp_port;
>> +
>> +                       if (!sp->udp_port || !port)
>> +                               sctp_assoc_update_frag_point(asoc);
>> +                       sp->udp_port = port;
>> +               }
>>        }


[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5257 bytes --]

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

* Re: [PATCH net-next 11/15] sctp: add udphdr to overhead when udp_port is set
  2020-10-05 19:01                                 ` Marcelo Ricardo Leitner
  2020-10-05 19:01                                   ` Marcelo Ricardo Leitner
  2020-10-05 20:08                                   ` Michael Tuexen
@ 2020-10-08  9:37                                   ` Xin Long
  2020-10-08  9:37                                     ` Xin Long
  2 siblings, 1 reply; 82+ messages in thread
From: Xin Long @ 2020-10-08  9:37 UTC (permalink / raw)
  To: Marcelo Ricardo Leitner
  Cc: kernel test robot, network dev, linux-sctp, kbuild-all,
	Neil Horman, Michael Tuexen, davem

On Tue, Oct 6, 2020 at 3:01 AM Marcelo Ricardo Leitner
<marcelo.leitner@gmail.com> wrote:
>
> On Sat, Oct 03, 2020 at 08:24:34PM +0800, Xin Long wrote:
> > On Sat, Oct 3, 2020 at 7:23 PM Xin Long <lucien.xin@gmail.com> wrote:
> > >
> > > On Sat, Oct 3, 2020 at 4:12 PM Xin Long <lucien.xin@gmail.com> wrote:
> > > >
> > > > On Sat, Oct 3, 2020 at 12:08 PM Marcelo Ricardo Leitner
> > > > <marcelo.leitner@gmail.com> wrote:
> > > > >
> > > > > On Wed, Sep 30, 2020 at 03:00:42AM +0800, kernel test robot wrote:
> > > > > > Hi Xin,
> > > > > >
> > > > > > Thank you for the patch! Yet something to improve:
> > > > >
> > > > > I wonder how are you planning to fix this. It is quite entangled.
> > > > > This is not performance critical. Maybe the cleanest way out is to
> > > > > move it to a .c file.
> > > > >
> > > > > Adding a
> > > > > #if defined(CONFIG_IP_SCTP) || defined(CONFIG_IP_SCTP_MODULE)
> > > > > in there doesn't seem good.
> > > > >
> > > > > >    In file included from include/net/sctp/checksum.h:27,
> > > > > >                     from net/netfilter/nf_nat_proto.c:16:
> > > > > >    include/net/sctp/sctp.h: In function 'sctp_mtu_payload':
> > > > > > >> include/net/sctp/sctp.h:583:31: error: 'struct net' has no member named 'sctp'; did you mean 'ct'?
> > > > > >      583 |   if (sock_net(&sp->inet.sk)->sctp.udp_port)
> > > > > >          |                               ^~~~
> > > > > >          |                               ct
> > > > > >
> > > > Here is actually another problem, I'm still thinking how to fix it.
> > > >
> > > > Now sctp_mtu_payload() returns different value depending on
> > > > net->sctp.udp_port. but net->sctp.udp_port can be changed by
> > > > "sysctl -w" anytime. so:
>
> Good point.
>
> > > >
> > > > In sctp_packet_config() it gets overhead/headroom by calling
> > > > sctp_mtu_payload(). When 'udp_port' is 0, it's IP+MAC header
> > > > size. Then if 'udp_port' is changed to 9899 by 'sysctl -w',
> > > > udphdr will also be added to the packet in sctp_v4_xmit(),
> > > > and later the headroom may not be enough for IP+MAC headers.
> > > >
> > > > I'm thinking to add sctp_sock->udp_port, and it'll be set when
> > > > the sock is created with net->udp_port. but not sure if we should
> > > > update sctp_sock->udp_port with  net->udp_port when sending packets?
>
> I don't think so,
>
> > > something like:
> ...
> > diff --git a/net/sctp/output.c b/net/sctp/output.c
> > index 6614c9fdc51e..c96b13ec72f4 100644
> > --- a/net/sctp/output.c
> > +++ b/net/sctp/output.c
> > @@ -91,6 +91,14 @@ void sctp_packet_config(struct sctp_packet *packet,
> > __u32 vtag,
> >         if (asoc) {
> >                 sk = asoc->base.sk;
> >                 sp = sctp_sk(sk);
> > +
> > +               if (unlikely(sp->udp_port != sock_net(sk)->sctp.udp_port)) {
>
> RFC6951 has:
>
> 6.1.  Get or Set the Remote UDP Encapsulation Port Number
>       (SCTP_REMOTE_UDP_ENCAPS_PORT)
> ...
>    sue_assoc_id:  This parameter is ignored for one-to-one style
>       sockets.  For one-to-many style sockets, the application may fill
>       in an association identifier or SCTP_FUTURE_ASSOC for this query.
>       It is an error to use SCTP_{CURRENT|ALL}_ASSOC in sue_assoc_id.
>
>    sue_address:  This specifies which address is of interest.  If a
>       wildcard address is provided, it applies only to future paths.
>
> So I'm not seeing a reason to have a system wide knob that takes
> effect in run time like this.
> Enable, start apps, and they keep behaving as initially configured.
> Need to disable? Restart the apps/sockets.
>
> Thoughts?
Right, not to update it on tx path makes more sense. Thanks.

>
> > +                       __u16 port = sock_net(sk)->sctp.udp_port;
> > +
> > +                       if (!sp->udp_port || !port)
> > +                               sctp_assoc_update_frag_point(asoc);
> > +                       sp->udp_port = port;
> > +               }
> >         }

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

* Re: [PATCH net-next 11/15] sctp: add udphdr to overhead when udp_port is set
  2020-10-08  9:37                                   ` Xin Long
@ 2020-10-08  9:37                                     ` Xin Long
  0 siblings, 0 replies; 82+ messages in thread
From: Xin Long @ 2020-10-08  9:37 UTC (permalink / raw)
  To: Marcelo Ricardo Leitner
  Cc: kernel test robot, network dev, linux-sctp, kbuild-all,
	Neil Horman, Michael Tuexen, davem

On Tue, Oct 6, 2020 at 3:01 AM Marcelo Ricardo Leitner
<marcelo.leitner@gmail.com> wrote:
>
> On Sat, Oct 03, 2020 at 08:24:34PM +0800, Xin Long wrote:
> > On Sat, Oct 3, 2020 at 7:23 PM Xin Long <lucien.xin@gmail.com> wrote:
> > >
> > > On Sat, Oct 3, 2020 at 4:12 PM Xin Long <lucien.xin@gmail.com> wrote:
> > > >
> > > > On Sat, Oct 3, 2020 at 12:08 PM Marcelo Ricardo Leitner
> > > > <marcelo.leitner@gmail.com> wrote:
> > > > >
> > > > > On Wed, Sep 30, 2020 at 03:00:42AM +0800, kernel test robot wrote:
> > > > > > Hi Xin,
> > > > > >
> > > > > > Thank you for the patch! Yet something to improve:
> > > > >
> > > > > I wonder how are you planning to fix this. It is quite entangled.
> > > > > This is not performance critical. Maybe the cleanest way out is to
> > > > > move it to a .c file.
> > > > >
> > > > > Adding a
> > > > > #if defined(CONFIG_IP_SCTP) || defined(CONFIG_IP_SCTP_MODULE)
> > > > > in there doesn't seem good.
> > > > >
> > > > > >    In file included from include/net/sctp/checksum.h:27,
> > > > > >                     from net/netfilter/nf_nat_proto.c:16:
> > > > > >    include/net/sctp/sctp.h: In function 'sctp_mtu_payload':
> > > > > > >> include/net/sctp/sctp.h:583:31: error: 'struct net' has no member named 'sctp'; did you mean 'ct'?
> > > > > >      583 |   if (sock_net(&sp->inet.sk)->sctp.udp_port)
> > > > > >          |                               ^~~~
> > > > > >          |                               ct
> > > > > >
> > > > Here is actually another problem, I'm still thinking how to fix it.
> > > >
> > > > Now sctp_mtu_payload() returns different value depending on
> > > > net->sctp.udp_port. but net->sctp.udp_port can be changed by
> > > > "sysctl -w" anytime. so:
>
> Good point.
>
> > > >
> > > > In sctp_packet_config() it gets overhead/headroom by calling
> > > > sctp_mtu_payload(). When 'udp_port' is 0, it's IP+MAC header
> > > > size. Then if 'udp_port' is changed to 9899 by 'sysctl -w',
> > > > udphdr will also be added to the packet in sctp_v4_xmit(),
> > > > and later the headroom may not be enough for IP+MAC headers.
> > > >
> > > > I'm thinking to add sctp_sock->udp_port, and it'll be set when
> > > > the sock is created with net->udp_port. but not sure if we should
> > > > update sctp_sock->udp_port with  net->udp_port when sending packets?
>
> I don't think so,
>
> > > something like:
> ...
> > diff --git a/net/sctp/output.c b/net/sctp/output.c
> > index 6614c9fdc51e..c96b13ec72f4 100644
> > --- a/net/sctp/output.c
> > +++ b/net/sctp/output.c
> > @@ -91,6 +91,14 @@ void sctp_packet_config(struct sctp_packet *packet,
> > __u32 vtag,
> >         if (asoc) {
> >                 sk = asoc->base.sk;
> >                 sp = sctp_sk(sk);
> > +
> > +               if (unlikely(sp->udp_port != sock_net(sk)->sctp.udp_port)) {
>
> RFC6951 has:
>
> 6.1.  Get or Set the Remote UDP Encapsulation Port Number
>       (SCTP_REMOTE_UDP_ENCAPS_PORT)
> ...
>    sue_assoc_id:  This parameter is ignored for one-to-one style
>       sockets.  For one-to-many style sockets, the application may fill
>       in an association identifier or SCTP_FUTURE_ASSOC for this query.
>       It is an error to use SCTP_{CURRENT|ALL}_ASSOC in sue_assoc_id.
>
>    sue_address:  This specifies which address is of interest.  If a
>       wildcard address is provided, it applies only to future paths.
>
> So I'm not seeing a reason to have a system wide knob that takes
> effect in run time like this.
> Enable, start apps, and they keep behaving as initially configured.
> Need to disable? Restart the apps/sockets.
>
> Thoughts?
Right, not to update it on tx path makes more sense. Thanks.

>
> > +                       __u16 port = sock_net(sk)->sctp.udp_port;
> > +
> > +                       if (!sp->udp_port || !port)
> > +                               sctp_assoc_update_frag_point(asoc);
> > +                       sp->udp_port = port;
> > +               }
> >         }

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

end of thread, other threads:[~2020-10-08  9:37 UTC | newest]

Thread overview: 82+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-29 13:48 [PATCH net-next 00/15] sctp: Implement RFC6951: UDP Encapsulation of SCTP Xin Long
2020-09-29 13:48 ` Xin Long
2020-09-29 13:48 ` [PATCH net-next 01/15] udp: check udp sock encap_type in __udp_lib_err Xin Long
2020-09-29 13:48   ` Xin Long
2020-09-29 13:48   ` [PATCH net-next 02/15] udp6: move the mss check after udp gso tunnel processing Xin Long
2020-09-29 13:48     ` Xin Long
2020-09-29 13:48     ` [PATCH net-next 03/15] udp: do checksum properly in skb_udp_tunnel_segment Xin Long
2020-09-29 13:48       ` Xin Long
2020-09-29 13:48       ` [PATCH net-next 04/15] udp: support sctp over udp " Xin Long
2020-09-29 13:48         ` Xin Long
2020-09-29 13:48         ` [PATCH net-next 05/15] sctp: create udp4 sock and add its encap_rcv Xin Long
2020-09-29 13:48           ` Xin Long
2020-09-29 13:48           ` [PATCH net-next 06/15] sctp: create udp6 sock and set " Xin Long
2020-09-29 13:48             ` Xin Long
2020-09-29 13:48             ` [PATCH net-next 07/15] sctp: add encap_err_lookup for udp encap socks Xin Long
2020-09-29 13:48               ` Xin Long
2020-09-29 13:49               ` [PATCH net-next 08/15] sctp: add encap_port for netns sock asoc and transport Xin Long
2020-09-29 13:49                 ` Xin Long
2020-09-29 13:49                 ` [PATCH net-next 09/15] sctp: add SCTP_REMOTE_UDP_ENCAPS_PORT sockopt Xin Long
2020-09-29 13:49                   ` Xin Long
2020-09-29 13:49                   ` [PATCH net-next 10/15] sctp: allow changing transport encap_port by peer packets Xin Long
2020-09-29 13:49                     ` Xin Long
2020-09-29 13:49                     ` [PATCH net-next 11/15] sctp: add udphdr to overhead when udp_port is set Xin Long
2020-09-29 13:49                       ` Xin Long
2020-09-29 13:49                       ` [PATCH net-next 12/15] sctp: call sk_setup_caps in sctp_packet_transmit instead Xin Long
2020-09-29 13:49                         ` Xin Long
2020-09-29 13:49                         ` [PATCH net-next 13/15] sctp: support for sending packet over udp4 sock Xin Long
2020-09-29 13:49                           ` Xin Long
2020-09-29 13:49                           ` [PATCH net-next 14/15] sctp: support for sending packet over udp6 sock Xin Long
2020-09-29 13:49                             ` Xin Long
2020-09-29 13:49                             ` [PATCH net-next 15/15] sctp: enable udp tunneling socks Xin Long
2020-09-29 13:49                               ` Xin Long
2020-10-03  4:12                               ` Marcelo Ricardo Leitner
2020-10-03  4:12                                 ` Marcelo Ricardo Leitner
2020-10-03  8:20                                 ` Xin Long
2020-10-03  8:20                                   ` Xin Long
2020-09-29 16:25                           ` [PATCH net-next 13/15] sctp: support for sending packet over udp4 sock kernel test robot
2020-09-29 16:25                             ` kernel test robot
2020-09-30  6:26                             ` Xin Long
2020-09-30  6:26                               ` Xin Long
2020-09-29 19:19                           ` kernel test robot
2020-09-29 19:19                             ` kernel test robot
2020-10-03  4:09                         ` [PATCH net-next 12/15] sctp: call sk_setup_caps in sctp_packet_transmit instead Marcelo Ricardo Leitner
2020-10-03  4:09                           ` Marcelo Ricardo Leitner
2020-10-03  7:45                           ` Xin Long
2020-10-03  7:45                             ` Xin Long
2020-09-29 19:00                       ` [PATCH net-next 11/15] sctp: add udphdr to overhead when udp_port is set kernel test robot
2020-09-29 19:00                         ` kernel test robot
2020-10-03  4:08                         ` Marcelo Ricardo Leitner
2020-10-03  4:08                           ` Marcelo Ricardo Leitner
2020-10-03  7:57                           ` Xin Long
2020-10-03  8:12                             ` Xin Long
2020-10-03 11:23                             ` Xin Long
2020-10-03 11:23                               ` Xin Long
2020-10-03 12:24                               ` Xin Long
2020-10-03 12:24                                 ` Xin Long
2020-10-05 19:01                                 ` Marcelo Ricardo Leitner
2020-10-05 19:01                                   ` Marcelo Ricardo Leitner
2020-10-05 20:08                                   ` Michael Tuexen
2020-10-05 20:08                                     ` Michael Tuexen
2020-10-08  9:37                                   ` Xin Long
2020-10-08  9:37                                     ` Xin Long
2020-10-03  4:07                       ` Marcelo Ricardo Leitner
2020-10-03  4:07                         ` Marcelo Ricardo Leitner
2020-10-03  7:54                         ` Xin Long
2020-10-03  7:54                           ` Xin Long
2020-10-03  4:06                     ` [PATCH net-next 10/15] sctp: allow changing transport encap_port by peer packets Marcelo Ricardo Leitner
2020-10-03  4:06                       ` Marcelo Ricardo Leitner
2020-10-03  4:05                   ` [PATCH net-next 09/15] sctp: add SCTP_REMOTE_UDP_ENCAPS_PORT sockopt Marcelo Ricardo Leitner
2020-10-03  4:05                     ` Marcelo Ricardo Leitner
2020-10-03  7:41                     ` Xin Long
2020-10-03  7:41                       ` Xin Long
2020-10-03  4:04       ` [PATCH net-next 03/15] udp: do checksum properly in skb_udp_tunnel_segment Marcelo Ricardo Leitner
2020-10-03  4:04         ` Marcelo Ricardo Leitner
2020-10-03  7:40         ` Xin Long
2020-10-03  7:40           ` Xin Long
2020-09-29 16:39 ` [PATCH net-next 00/15] sctp: Implement RFC6951: UDP Encapsulation of SCTP Michael Tuexen
2020-09-29 16:39   ` Michael Tuexen
2020-09-29 17:49   ` Xin Long
2020-09-29 18:04     ` Xin Long
2020-10-01 12:41 ` Marcelo Ricardo Leitner
2020-10-01 12:41   ` Marcelo Ricardo Leitner

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).