sctp: Implement RFC6951: UDP Encapsulation of SCTP
Subsystems (4)
Xin Long
maintainercover sctp: Implement RFC6951: UDP Encapsulation of SCTP
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(-)
Signature · 1 line
2.1.0
Xin Long
maintainerPATCH 1/15 udp: check udp sock encap_type in __udp_lib_err
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.
--- net/ipv4/udp.c | 2 +- net/ipv6/udp.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
net/ipv4/udp.c +1 -1
@@ -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)) {
net/ipv6/udp.c +1 -1
@@ -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)) {
Signature · 1 line
2.1.0
Xin Long
maintainerPATCH 2/15 udp6: move the mss check after udp gso tunnel processing
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.
--- net/ipv6/udp_offload.c | 154 ++++++++++++++++++++++++------------------------- 1 file changed, 76 insertions(+), 78 deletions(-)
net/ipv6/udp_offload.c +76 -78
@@ -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; }
Signature · 1 line
2.1.0
Xin Long
maintainerPATCH 3/15 udp: do checksum properly in skb_udp_tunnel_segment
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.
--- net/ipv4/udp_offload.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
net/ipv4/udp_offload.c +6 -5
@@ -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:
Signature · 1 line
2.1.0
Xin Long
maintainerPATCH 4/15 udp: support sctp over udp in skb_udp_tunnel_segment
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.
--- net/ipv4/udp_offload.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
net/ipv4/udp_offload.c +7 -2
@@ -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 ;
Signature · 1 line
2.1.0
Xin Long
maintainerPATCH 5/15 sctp: create udp4 sock and add its encap_rcv
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.
--- 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(+)
include/net/netns/sctp.h +5 -0
@@ -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.
include/net/sctp/constants.h +2 -0
@@ -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. */
include/net/sctp/sctp.h +2 -0
@@ -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
net/sctp/protocol.c +40 -0
@@ -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 ;
Signature · 1 line
2.1.0
Xin Long
maintainerPATCH 6/15 sctp: create udp6 sock and set its encap_rcv
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.
--- include/net/netns/sctp.h | 1 + net/sctp/protocol.c | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+)
include/net/netns/sctp.h +1 -0
@@ -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;
net/sctp/protocol.c +23 -0
@@ -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. */
Signature · 1 line
2.1.0
Xin Long
maintainerPATCH 7/15 sctp: add encap_err_lookup for udp encap socks
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.
--- net/sctp/protocol.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
net/sctp/protocol.c +19 -0
@@ -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;
Signature · 1 line
2.1.0
Xin Long
maintainerPATCH 8/15 sctp: add encap_port for netns sock asoc and transport
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.
--- 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(+)
include/net/netns/sctp.h +2 -0
@@ -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
include/net/sctp/structs.h +6 -0
@@ -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. */
net/sctp/associola.c +4 -0
@@ -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;
net/sctp/protocol.c +3 -0
@@ -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 ;
net/sctp/socket.c +1 -0
@@ -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;
net/sctp/sysctl.c +1 -0
@@ -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),
Signature · 1 line
2.1.0
Xin Long
maintainerPATCH 9/15 sctp: add SCTP_REMOTE_UDP_ENCAPS_PORT sockopt
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.
--- include/uapi/linux/sctp.h | 7 +++ net/sctp/socket.c | 110 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 117 insertions(+)
include/uapi/linux/sctp.h +7 -0
@@ -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 ,
net/sctp/socket.c +110 -0
134 lines not on this page · raw message
Signature · 1 line
2.1.0
Xin Long
maintainerPATCH 10/15 sctp: allow changing transport encap_port by peer packets
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.
--- 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(-)
include/net/sctp/sm.h +1 -0
@@ -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 ; }
include/net/sctp/structs.h +1 -6
@@ -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]))
net/sctp/ipv6.c +1 -0
@@ -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 ; }
net/sctp/protocol.c +10 -1
@@ -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 ,
net/sctp/sm_make_chunk.c +1 -0
@@ -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;
net/sctp/sm_statefuns.c +2 -0
@@ -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. */
Signature · 1 line
2.1.0
Xin Long
maintainerPATCH 11/15 sctp: add udphdr to overhead when udp_port is set
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.
--- include/net/sctp/sctp.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
include/net/sctp/sctp.h +5 -2
@@ -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;
Signature · 1 line
2.1.0
Xin Long
maintainerPATCH 12/15 sctp: call sk_setup_caps in sctp_packet_transmit instead
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().
--- net/sctp/output.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
net/sctp/output.c +7 -6
@@ -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) {
Signature · 1 line
2.1.0
Xin Long
maintainerPATCH 13/15 sctp: support for sending packet over udp4 sock
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.
--- net/sctp/output.c | 9 +++------ net/sctp/protocol.c | 44 +++++++++++++++++++++++++++++++++----------- 2 files changed, 36 insertions(+), 17 deletions(-)
net/sctp/output.c +3 -6
@@ -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) {
net/sctp/protocol.c +33 -11
64 lines not on this page · raw message
Signature · 1 line
2.1.0
Xin Long
maintainerPATCH 14/15 sctp: support for sending packet over udp6 sock
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.
--- net/sctp/ipv6.c | 47 +++++++++++++++++++++++++++++++++++------------ 1 file changed, 35 insertions(+), 12 deletions(-)
net/sctp/ipv6.c +35 -12
@@ -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
Signature · 1 line
2.1.0
Xin Long
maintainerPATCH 15/15 sctp: enable udp tunneling socks
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.
--- net/sctp/protocol.c | 5 +++++ net/sctp/sysctl.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+)
net/sctp/protocol.c +5 -0
@@ -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 = {
net/sctp/sysctl.c +43 -0
61 lines not on this page · raw message
Signature · 1 line
2.1.0
Marcelo Ricardo Leitner
maintainerRe: [PATCH net-next 15/15] sctp: enable udp tunneling socks
Quoted 8 lines · Xin Long
This patch is to enable udp tunneling socks by calling
sctp_udp_sock_start()insctp_ctrlsock_init(), andsctp_udp_sock_stop()insctp_ctrlsock_exit().Also add sysctl
udp_portto allow changing the listening sock's port by users.Wit this patch, the whole sctp over udp feature can be
With
Quoted 1 line
enabled and used.
...
net/sctp/protocol.c static int __net_init sctp_ctrlsock_init(struct net *net) · line 1469
Quoted 5 lines
net/sctp/protocol.c +1
-0@@ -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.
net/sctp/protocol.c static int __net_init sctp_ctrlsock_init(struct net *net) · line 1471
Quoted 2 lines
net/sctp/protocol.c +2
-0+if (status) +pr_err ("Failed to initialize the SCTP udp tunneling sock\n" );
SCTP UDP
net/sctp/protocol.c static int __net_init sctp_ctrlsock_init(struct net *net) · line 1475
Quoted 4 lines
net/sctp/protocol.c +1
-0+return status; }
This is the last comment I had.
Thanks Xin! Nice patches.
Xin Long
maintainerRe: [PATCH net-next 15/15] sctp: enable udp tunneling socks
Quoted 13 lines · Marcelo Ricardo Leitner
Quoted 8 lines · Xin Long
This patch is to enable udp tunneling socks by calling
sctp_udp_sock_start()insctp_ctrlsock_init(), andsctp_udp_sock_stop()insctp_ctrlsock_exit().Also add sysctl
udp_portto allow changing the listening sock's port by users.Wit this patch, the whole sctp over udp feature can be
With
Quoted 1 line
enabled and used.
Quoted 8 lines
...
net/sctp/protocol.c static int __net_init sctp_ctrlsock_init(struct net *net) · line 1469
Quoted 5 lines
net/sctp/protocol.c +1
-0@@ -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().
Quoted 5 lines
net/sctp/protocol.c static int __net_init sctp_ctrlsock_init(struct net *net) · line 1471
Quoted 3 lines
net/sctp/protocol.c +2
-0+if (status) +pr_err ("Failed to initialize the SCTP udp tunneling sock\n" );SCTP UDP
Quoted 7 lines
net/sctp/protocol.c static int __net_init sctp_ctrlsock_init(struct net *net) · line 1475
Quoted 4 lines
net/sctp/protocol.c +1
-0+return status; }This is the last comment I had.
Thanks Xin! Nice patches.
Thanks for checking so carefully!
kernel test robot
build botRe: [PATCH net-next 13/15] sctp: support for sending packet over udp4 sock
In reply to Xin LongThank you for the patch! Yet something to improve:
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
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_ipvim +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/[email protected]
Xin Long
maintainerRe: [PATCH net-next 13/15] sctp: support for sending packet over udp4 sock
Quoted 66 lines · kernel test robot
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.0reproduce (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 checkouta1016fd4a55f176fcc2eae05052a61ad7d5a142b
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=ia64If you fix the issue, kindly add following tag as appropriate
Reported-by kernel test robot <[email protected]>All errors (new ones prefixed by >>):
net/sctp/protocol.c: In function 'sctp_udp_sock_start':Quoted 1 line
Quoted 1 line
net/sctp/protocol.c:894:11: error: 'structudp_port_cfg' has no member named 'local_ip6'; did you mean 'local_ip'?894 | udp_conf.local_ip6 = in6addr_any; | ^~~~~~~~~ | local_ipvim +894
net/sctp/protocol.ca330bee1c278f8 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;
Quoted 8 lines
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.
Quoted 8 lines
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/[email protected]
kernel test robot
build botRe: [PATCH net-next 13/15] sctp: support for sending packet over udp4 sock
In reply to Xin LongThank you for the patch! Yet something to improve:
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
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/[email protected]
Marcelo Ricardo Leitner
maintainerRe: [PATCH net-next 12/15] sctp: call sk_setup_caps in sctp_packet_transmit instead
In reply to Xin LongQuoted 8 lines · Xin Long
sk_setup_caps()was originally called in Commit90017accff61("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"
Quoted 1 line
before
sctp_packet_pack().
Xin Long
maintainerRe: [PATCH net-next 12/15] sctp: call sk_setup_caps in sctp_packet_transmit instead
Quoted 5 lines · Marcelo Ricardo Leitner
Quoted 3 lines · Xin Long
sk_setup_caps()was originally called in Commit90017accff61("sctp:
Add GSO support"), as:
Quoted 7 lines
Quoted 5 lines
"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 andTo be more precise, "shouldn't be tied to gso"
right.
Quoted 2 lines
Quoted 2 lines
before
sctp_packet_pack().
kernel test robot
build botRe: [PATCH net-next 11/15] sctp: add udphdr to overhead when udp_port is set
In reply to Xin LongThank you for the patch! Yet something to improve:
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
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)
| ^~~~
| ctvim +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/[email protected]
Marcelo Ricardo Leitner
maintainerRe: [PATCH net-next 11/15] sctp: add udphdr to overhead when udp_port is set
Quoted 3 lines · kernel test robot
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.
Quoted 8 lines
In file included from
include/net/sctp/checksum.h:27,
fromnet/netfilter/nf_nat_proto.c:16:
include/net/sctp/sctp.h: In function 'sctp_mtu_payload':Quoted 1 line
Quoted 1 line
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
Xin Long
maintainerRe: [PATCH net-next 11/15] sctp: add udphdr to overhead when udp_port is set
Quoted 6 lines · Marcelo Ricardo Leitner
Quoted 3 lines · kernel test robot
Hi Xin,
Thank you for the patch! Yet something to improve:
Quoted 16 lines
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
#ifdefined(CONFIG_IP_SCTP)||defined(CONFIG_IP_SCTP_MODULE)in there doesn't seem good.Quoted 8 lines
In file included from
include/net/sctp/checksum.h:27,
fromnet/netfilter/nf_nat_proto.c:16:
include/net/sctp/sctp.h: In function 'sctp_mtu_payload':Quoted 1 line
Quoted 1 line
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?
Xin Long
maintainerRe: [PATCH net-next 11/15] sctp: add udphdr to overhead when udp_port is set
Quoted 37 lines · Xin Long
Quoted 6 lines · Marcelo Ricardo Leitner
Quoted 3 lines · kernel test robot
Hi Xin,
Thank you for the patch! Yet something to improve:
Quoted 16 lines
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
#ifdefined(CONFIG_IP_SCTP)||defined(CONFIG_IP_SCTP_MODULE)in there doesn't seem good.Quoted 8 lines
In file included from
include/net/sctp/checksum.h:27,
fromnet/netfilter/nf_nat_proto.c:16:
include/net/sctp/sctp.h: In function 'sctp_mtu_payload':Quoted 1 line
Quoted 1 line
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) | ^~~~ | ctHere is actually another problem, I'm still thinking how to fix it.
Now
sctp_mtu_payload()returns different value depending onnet->sctp.udp_port. butnet->sctp.udp_portcan be changed by "sysctl -w" anytime. so:In
sctp_packet_config()it gets overhead/headroom by callingsctp_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 insctp_v4_xmit(), and later the headroom may not be enough for IP+MAC headers.
Quoted 3 lines
I'm thinking to add
sctp_sock->udp_port, and it'll be set when the sock is created withnet->udp_port. but not sure if we should updatesctp_sock->udp_portwithnet->udp_portwhen sending packets?
something like:
net/sctp/output.c +0 -0
@@ -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;net/sctp/sm_make_chunk.c +0 -0
@@ -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));net/sctp/sm_statefuns.c +2 -0
@@ -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 );
net/sctp/socket.c +0 -0
@@ -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;Xin Long
maintainerRe: [PATCH net-next 11/15] sctp: add udphdr to overhead when udp_port is set
Quoted 115 lines · Xin Long
Quoted 37 lines · Xin Long
Quoted 6 lines · Marcelo Ricardo Leitner
Quoted 3 lines · kernel test robot
Hi Xin,
Thank you for the patch! Yet something to improve:
Quoted 16 lines
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
#ifdefined(CONFIG_IP_SCTP)||defined(CONFIG_IP_SCTP_MODULE)in there doesn't seem good.Quoted 8 lines
In file included from
include/net/sctp/checksum.h:27,
fromnet/netfilter/nf_nat_proto.c:16:
include/net/sctp/sctp.h: In function 'sctp_mtu_payload':Quoted 1 line
Quoted 1 line
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) | ^~~~ | ctHere is actually another problem, I'm still thinking how to fix it.
Now
sctp_mtu_payload()returns different value depending onnet->sctp.udp_port. butnet->sctp.udp_portcan be changed by "sysctl -w" anytime. so:In
sctp_packet_config()it gets overhead/headroom by callingsctp_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 insctp_v4_xmit(), and later the headroom may not be enough for IP+MAC headers.Quoted 3 lines
I'm thinking to add
sctp_sock->udp_port, and it'll be set when the sock is created withnet->udp_port. but not sure if we should updatesctp_sock->udp_portwithnet->udp_portwhen sending packets?something like:
net/sctp/output.c +1
-0@@ -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;net/sctp/sm_make_chunk.c +1
-0@@ -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));net/sctp/sm_statefuns.c +2
-0@@ -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 );net/sctp/socket.c +11
-0@@ -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()andrecvmsg()calls to transmit data tonet/sctp/socket.c +2
-0@@ -1795,6 +1806,8 @@ static int sctp_sendmsg_to_asoc(structsctp_association *asoc, goto err; } +sctp_sock_check_udp_port (net, sp, asoc); +if (sp->disable_fragments && msg_len > asoc->frag_point) { err = -EMSGSIZE ;
Quoted 1 line
goto err;
include/net/sctp/sctp.h +0 -0
@@ -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);net/sctp/output.c +0 -0
@@ -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;
+ }
}
net/sctp/sm_statefuns.c +2 -0
@@ -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.
Marcelo Ricardo Leitner
maintainerRe: [PATCH net-next 11/15] sctp: add udphdr to overhead when udp_port is set
Quoted 28 lines · Xin Long
Quoted 27 lines · Xin Long
Quoted 25 lines · Xin Long
Quoted 22 lines · Marcelo Ricardo Leitner
Quoted 3 lines · kernel test robot
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
#ifdefined(CONFIG_IP_SCTP)||defined(CONFIG_IP_SCTP_MODULE)in there doesn't seem good.Quoted 8 lines
In file included from
include/net/sctp/checksum.h:27,
fromnet/netfilter/nf_nat_proto.c:16:
include/net/sctp/sctp.h: In function 'sctp_mtu_payload':Quoted 1 line
Quoted 1 line
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
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Here is actually another problem, I'm still thinking how to fix it.
Now
sctp_mtu_payload()returns different value depending onnet->sctp.udp_port. butnet->sctp.udp_portcan be changed by "sysctl -w" anytime. so:
Good point.
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
In
sctp_packet_config()it gets overhead/headroom by callingsctp_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 insctp_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 withnet->udp_port. but not sure if we should updatesctp_sock->udp_portwithnet->udp_portwhen sending packets?
I don't think so,
Quoted 1 line
Quoted 1 line
something like:
...
net/sctp/output.c void sctp_packet_config(struct sctp_packet *packet, · line 96
Quoted 11 lines
net/sctp/output.c +2
-0@@ -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?
Quoted 7 lines
net/sctp/output.c +6
-0+__u16 port =sock_net (sk)->sctp.udp_port; + +if (!sp->udp_port || !port) +sctp_assoc_update_frag_point (asoc); + sp->udp_port = port; + } }
Re: [PATCH net-next 11/15] sctp: add udphdr to overhead when udp_port is set
Quoted 79 lines · Marcelo Ricardo Leitner
Quoted 28 lines · Xin Long
Quoted 27 lines · Xin Long
Quoted 25 lines · Xin Long
Quoted 22 lines · Marcelo Ricardo Leitner
Quoted 3 lines · kernel test robot
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
#ifdefined(CONFIG_IP_SCTP)||defined(CONFIG_IP_SCTP_MODULE)in there doesn't seem good.Quoted 8 lines
In file included from
include/net/sctp/checksum.h:27,
fromnet/netfilter/nf_nat_proto.c:16:
include/net/sctp/sctp.h: In function 'sctp_mtu_payload':Quoted 1 line
Quoted 1 line
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) | ^~~~ | ctQuoted 5 lines
Quoted 5 lines
Quoted 5 lines
Here is actually another problem, I'm still thinking how to fix it.
Now
sctp_mtu_payload()returns different value depending onnet->sctp.udp_port. butnet->sctp.udp_portcan be changed by "sysctl -w" anytime. so:Good point.
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
In
sctp_packet_config()it gets overhead/headroom by callingsctp_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 insctp_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 withnet->udp_port. but not sure if we should updatesctp_sock->udp_portwithnet->udp_portwhen sending packets?I don't think so,
Quoted 1 line
Quoted 1 line
something like:
...
net/sctp/output.c void sctp_packet_config(struct sctp_packet *packet, · line 96
Quoted 11 lines
net/sctp/output.c +2
-0@@ -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 orSCTP_FUTURE_ASSOCfor this query. It is an error to use SCTP_{CURRENT|ALL}_ASSOC insue_assoc_id.
sue_address: This specifies which address is of interest. If a
wildcard address is provided, it applies only to future paths.
Quoted 6 lines
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
Quoted 8 lines
Quoted 8 lines
net/sctp/output.c +6
-0+__u16 port =sock_net (sk)->sctp.udp_port; + +if (!sp->udp_port || !port) +sctp_assoc_update_frag_point (asoc); + sp->udp_port = port; + } }
Xin Long
maintainerRe: [PATCH net-next 11/15] sctp: add udphdr to overhead when udp_port is set
In reply to Marcelo Ricardo LeitnerQuoted 78 lines · Marcelo Ricardo Leitner
Quoted 28 lines · Xin Long
Quoted 27 lines · Xin Long
Quoted 25 lines · Xin Long
Quoted 22 lines · Marcelo Ricardo Leitner
Quoted 3 lines · kernel test robot
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
#ifdefined(CONFIG_IP_SCTP)||defined(CONFIG_IP_SCTP_MODULE)in there doesn't seem good.Quoted 8 lines
In file included from
include/net/sctp/checksum.h:27,
fromnet/netfilter/nf_nat_proto.c:16:
include/net/sctp/sctp.h: In function 'sctp_mtu_payload':Quoted 1 line
Quoted 1 line
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) | ^~~~ | ctQuoted 5 lines
Quoted 5 lines
Quoted 5 lines
Here is actually another problem, I'm still thinking how to fix it.
Now
sctp_mtu_payload()returns different value depending onnet->sctp.udp_port. butnet->sctp.udp_portcan be changed by "sysctl -w" anytime. so:Good point.
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
In
sctp_packet_config()it gets overhead/headroom by callingsctp_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 insctp_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 withnet->udp_port. but not sure if we should updatesctp_sock->udp_portwithnet->udp_portwhen sending packets?I don't think so,
Quoted 1 line
Quoted 1 line
something like:
...
net/sctp/output.c void sctp_packet_config(struct sctp_packet *packet, · line 96
Quoted 11 lines
net/sctp/output.c +2
-0@@ -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 orSCTP_FUTURE_ASSOCfor this query. It is an error to use SCTP_{CURRENT|ALL}_ASSOC insue_assoc_id.
sue_address: This specifies which address is of interest. If a
wildcard address is provided, it applies only to future paths.
Quoted 6 lines
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.
Quoted 8 lines
Quoted 8 lines
net/sctp/output.c +6
-0+__u16 port =sock_net (sk)->sctp.udp_port; + +if (!sp->udp_port || !port) +sctp_assoc_update_frag_point (asoc); + sp->udp_port = port; + } }
Marcelo Ricardo Leitner
maintainerRe: [PATCH net-next 11/15] sctp: add udphdr to overhead when udp_port is set
In reply to Xin LongQuoted 3 lines · Xin Long
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" ^^^^
Quoted 7 lines
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./ ?
Xin Long
maintainerRe: [PATCH net-next 11/15] sctp: add udphdr to overhead when udp_port is set
Quoted 6 lines · Marcelo Ricardo Leitner
Quoted 3 lines · Xin Long
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
Quoted 8 lines
Quoted 7 lines
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.
Quoted 6 lines
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.
Marcelo Ricardo Leitner
maintainerRe: [PATCH net-next 10/15] sctp: allow changing transport encap_port by peer packets
In reply to Xin Longnet/sctp/protocol.c static int sctp_ctl_sock_init(struct net *net) · line 846
Quoted 4 lines · Xin Long
static int
sctp_udp_rcv(struct sock *sk, struct sk_buff *skb){net/sctp/protocol.c +2
-0+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.
Quoted 4 lines
net/sctp/protocol.c +1
-0+skb_set_transport_header (skb,sizeof (struct udphdr ));sctp_rcv (skb);return 0 ;
Marcelo Ricardo Leitner
maintainerRe: [PATCH net-next 09/15] sctp: add SCTP_REMOTE_UDP_ENCAPS_PORT sockopt
In reply to Xin LongOn Tue, Sep 29, 2020 at 09:49:01PM +0800, Xin Long wrote:
...
Quoted 5 lines
include/uapi/linux/sctp.h +5
-0+struct sctp_udpencaps { +sctp_assoc_t sue_assoc_id; +struct sockaddr_storage sue_address; +uint16_t sue_port; +};
...
Quoted 10 lines
net/sctp/socket.c +10
-0+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 ; +
net/sctp/socket.c static int sctp_setsockopt_pf_expose(struct sock *sk, · line 4439
Quoted 10 lines
net/sctp/socket.c +10
-0+/* 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.
Xin Long
maintainerRe: [PATCH net-next 09/15] sctp: add SCTP_REMOTE_UDP_ENCAPS_PORT sockopt
Quoted 31 lines · Marcelo Ricardo Leitner
On Tue, Sep 29, 2020 at 09:49:01PM +0800, Xin Long wrote:
...Quoted 5 lines
include/uapi/linux/sctp.h +5
-0+struct sctp_udpencaps { +sctp_assoc_t sue_assoc_id; +struct sockaddr_storage sue_address; +uint16_t sue_port; +};...
Quoted 10 lines
net/sctp/socket.c +10
-0+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 ; +net/sctp/socket.c static int sctp_setsockopt_pf_expose(struct sock *sk, · line 4439
Quoted 10 lines
net/sctp/socket.c +10
-0+/* 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;^^^^^^^^^^ ^^^^^^^^
Quoted 6 lines
encap_portis defined as__u16is previous patch, but from RFC:
sue_port: The UDP port number in network byte order...
asoc->peer.portis stored in host order, so it makes sense to follow it here. Then need ahtons()here and its counter parts. It is right in some parts of the patches already.
Good catch! thank you!
Marcelo Ricardo Leitner
maintainerRe: [PATCH net-next 03/15] udp: do checksum properly in skb_udp_tunnel_segment
In reply to Xin LongQuoted 10 lines · Xin Long
This patch fixes two things:
When
skb->ip_summed=CHECKSUM_PARTIAL,skb_checksum_help()should be called do the checksum, instead ofgso_make_checksum(), which is used to do the checksum for current proto after callingskb_segment(), not after the inner proto'sgso_segment().When
offload_csumis disabled, the hardware will not do the checksum for the current proto, udp. So instead of callinggso_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.
Xin Long
maintainerRe: [PATCH net-next 03/15] udp: do checksum properly in skb_udp_tunnel_segment
Quoted 9 lines · Marcelo Ricardo Leitner
Quoted 7 lines · Xin Long
This patch fixes two things:
When
skb->ip_summed==CHECKSUM_PARTIAL,skb_checksum_help()should be called do the checksum, instead ofgso_make_checksum(), which is used to do the checksum for current proto after callingskb_segment(), not after the inner proto'sgso_segment().
Quoted 6 lines
Quoted 3 lines
When
offload_csumis disabled, the hardware will not do the checksum for the current proto, udp. So instead of callinggso_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.
Quoted 3 lines
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.
Quoted 35 lines · Xin Long
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.
Quoted 3 lines
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
Quoted 71 lines
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_checksumenabled/disabled, with UDP Encapsulation enabled/disabled:No clear performance dropped.
Xin Long (15):
udp: check udp sockencap_typein__udp_lib_err
udp6: move the mss check after udp gso tunnel processing
udp: do checksum properly inskb_udp_tunnel_segment
udp: support sctp over udp inskb_udp_tunnel_segment
sctp: create udp4 sock and add itsencap_rcv
sctp: create udp6 sock and set itsencap_rcv
sctp: addencap_err_lookupfor udp encap socks
sctp: addencap_portfor netns sock asoc and transport
sctp: addSCTP_REMOTE_UDP_ENCAPS_PORTsockopt
sctp: allow changing transportencap_portby peer packets
sctp: add udphdr to overhead whenudp_portis set
sctp: callsk_setup_capsinsctp_packet_transmitinstead
sctp: support for sending packet over udp4 sock
sctp: support for sending packet over udp6 sock
sctp: enable udp tunneling socksinclude/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(-)Signature · 1 line
2.1.0
Xin Long
maintainerQuoted 39 lines · Michael Tuexen
Quoted 36 lines · Xin Long
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.
Quoted 3 lines
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.
Quoted 7 lines
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.
Quoted 4 lines
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.
Quoted 4 lines
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.
Marcelo Ricardo Leitner
maintainerOn Tue, Sep 29, 2020 at 09:48:52PM +0800, Xin Long wrote:
...
Quoted 1 line
Patches:
Please give me till tomorrow for revising this patchset.
Thanks,
Marcelo