From: Xin Long <lucien.xin@gmail.com> To: network dev <netdev@vger.kernel.org>, linux-sctp@vger.kernel.org Cc: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>, Neil Horman <nhorman@tuxdriver.com>, Michael Tuexen <tuexen@fh-muenster.de>, davem@davemloft.net Subject: [PATCHv2 net-next 14/17] sctp: support for sending packet over udp6 sock Date: Thu, 08 Oct 2020 09:48:10 +0000 [thread overview] Message-ID: <5c0e9cf835f54c11f7e3014cab926bf10a47298d.1602150362.git.lucien.xin@gmail.com> (raw) In-Reply-To: <1d1b2e92f958add640d5be1e6eaec1ac5e4581ce.1602150362.git.lucien.xin@gmail.com> 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. v1->v2: - Use sp->udp_port instead in sctp_v6_xmit(), which is more safe. Signed-off-by: Xin Long <lucien.xin@gmail.com> --- net/sctp/ipv6.c | 43 ++++++++++++++++++++++++++++++++----------- 1 file changed, 32 insertions(+), 11 deletions(-) diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c index a064bf2..814754d 100644 --- a/net/sctp/ipv6.c +++ b/net/sctp/ipv6.c @@ -55,6 +55,7 @@ #include <net/inet_common.h> #include <net/inet_ecn.h> #include <net/sctp/sctp.h> +#include <net/udp_tunnel.h> #include <linux/uaccess.h> @@ -191,33 +192,53 @@ 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; __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); - 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 || !sctp_sk(sk)->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(sock_net(sk), skb, fl6->flowlabel, true, fl6); + + return udp_tunnel6_xmit_skb(dst, sk, skb, NULL, &fl6->saddr, + &fl6->daddr, tclass, ip6_dst_hoplimit(dst), + label, sctp_sk(sk)->udp_port, t->encap_port, false); } /* Returns the dst cache entry for the given source and destination ip -- 2.1.0
WARNING: multiple messages have this Message-ID (diff)
From: Xin Long <lucien.xin@gmail.com> To: network dev <netdev@vger.kernel.org>, linux-sctp@vger.kernel.org Cc: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>, Neil Horman <nhorman@tuxdriver.com>, Michael Tuexen <tuexen@fh-muenster.de>, davem@davemloft.net Subject: [PATCHv2 net-next 14/17] sctp: support for sending packet over udp6 sock Date: Thu, 8 Oct 2020 17:48:10 +0800 [thread overview] Message-ID: <5c0e9cf835f54c11f7e3014cab926bf10a47298d.1602150362.git.lucien.xin@gmail.com> (raw) Message-ID: <20201008094810.kM8C9jQgbjoDt_a3-P7BupbtWEkmr96BxjYvKEv7B_4@z> (raw) In-Reply-To: <1d1b2e92f958add640d5be1e6eaec1ac5e4581ce.1602150362.git.lucien.xin@gmail.com> In-Reply-To: <cover.1602150362.git.lucien.xin@gmail.com> 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. v1->v2: - Use sp->udp_port instead in sctp_v6_xmit(), which is more safe. Signed-off-by: Xin Long <lucien.xin@gmail.com> --- net/sctp/ipv6.c | 43 ++++++++++++++++++++++++++++++++----------- 1 file changed, 32 insertions(+), 11 deletions(-) diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c index a064bf2..814754d 100644 --- a/net/sctp/ipv6.c +++ b/net/sctp/ipv6.c @@ -55,6 +55,7 @@ #include <net/inet_common.h> #include <net/inet_ecn.h> #include <net/sctp/sctp.h> +#include <net/udp_tunnel.h> #include <linux/uaccess.h> @@ -191,33 +192,53 @@ 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; __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); - 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 || !sctp_sk(sk)->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(sock_net(sk), skb, fl6->flowlabel, true, fl6); + + return udp_tunnel6_xmit_skb(dst, sk, skb, NULL, &fl6->saddr, + &fl6->daddr, tclass, ip6_dst_hoplimit(dst), + label, sctp_sk(sk)->udp_port, t->encap_port, false); } /* Returns the dst cache entry for the given source and destination ip -- 2.1.0
next prev parent reply other threads:[~2020-10-08 9:48 UTC|newest] Thread overview: 62+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-10-08 9:47 [PATCHv2 net-next 00/17] sctp: Implement RFC6951: UDP Encapsulation of SCTP Xin Long 2020-10-08 9:47 ` Xin Long 2020-10-08 9:47 ` [PATCHv2 net-next 01/17] udp: check udp sock encap_type in __udp_lib_err Xin Long 2020-10-08 9:47 ` Xin Long 2020-10-08 9:47 ` [PATCHv2 net-next 02/17] udp6: move the mss check after udp gso tunnel processing Xin Long 2020-10-08 9:47 ` Xin Long 2020-10-08 9:47 ` [PATCHv2 net-next 03/17] udp: do checksum properly in skb_udp_tunnel_segment Xin Long 2020-10-08 9:47 ` Xin Long 2020-10-08 9:48 ` [PATCHv2 net-next 04/17] udp: support sctp over udp " Xin Long 2020-10-08 9:48 ` Xin Long 2020-10-08 9:48 ` [PATCHv2 net-next 05/17] sctp: create udp4 sock and add its encap_rcv Xin Long 2020-10-08 9:48 ` Xin Long 2020-10-08 9:48 ` [PATCHv2 net-next 06/17] sctp: create udp6 sock and set " Xin Long 2020-10-08 9:48 ` Xin Long 2020-10-08 9:48 ` [PATCHv2 net-next 07/17] sctp: add encap_err_lookup for udp encap socks Xin Long 2020-10-08 9:48 ` Xin Long 2020-10-08 9:48 ` [PATCHv2 net-next 08/17] sctp: add encap_port for netns sock asoc and transport Xin Long 2020-10-08 9:48 ` Xin Long 2020-10-08 9:48 ` [PATCHv2 net-next 09/17] sctp: add SCTP_REMOTE_UDP_ENCAPS_PORT sockopt Xin Long 2020-10-08 9:48 ` Xin Long 2020-10-08 9:48 ` [PATCHv2 net-next 10/17] sctp: allow changing transport encap_port by peer packets Xin Long 2020-10-08 9:48 ` Xin Long 2020-10-08 9:48 ` [PATCHv2 net-next 11/17] sctp: add udphdr to overhead when udp_port is set Xin Long 2020-10-08 9:48 ` Xin Long 2020-10-08 9:48 ` [PATCHv2 net-next 12/17] sctp: call sk_setup_caps in sctp_packet_transmit instead Xin Long 2020-10-08 9:48 ` Xin Long 2020-10-08 9:48 ` [PATCHv2 net-next 13/17] sctp: support for sending packet over udp4 sock Xin Long 2020-10-08 9:48 ` Xin Long 2020-10-08 9:48 ` Xin Long [this message] 2020-10-08 9:48 ` [PATCHv2 net-next 14/17] sctp: support for sending packet over udp6 sock Xin Long 2020-10-08 9:48 ` [PATCHv2 net-next 15/17] sctp: add the error cause for new encapsulation port restart Xin Long 2020-10-08 9:48 ` Xin Long 2020-10-08 9:48 ` [PATCHv2 net-next 16/17] sctp: handle the init chunk matching an existing asoc Xin Long 2020-10-08 9:48 ` Xin Long 2020-10-08 9:48 ` [PATCHv2 net-next 17/17] sctp: enable udp tunneling socks Xin Long 2020-10-08 9:48 ` Xin Long 2020-10-08 15:46 ` kernel test robot 2020-10-08 15:46 ` kernel test robot 2020-10-09 2:02 ` Xin Long 2020-10-09 2:02 ` Xin Long 2020-10-08 14:33 ` [PATCHv2 net-next 15/17] sctp: add the error cause for new encapsulation port restart kernel test robot 2020-10-08 14:33 ` kernel test robot 2020-10-08 13:10 ` [PATCHv2 net-next 09/17] sctp: add SCTP_REMOTE_UDP_ENCAPS_PORT sockopt kernel test robot 2020-10-08 13:10 ` kernel test robot 2020-10-08 21:18 ` [PATCHv2 net-next 06/17] sctp: create udp6 sock and set its encap_rcv kernel test robot 2020-10-08 21:18 ` kernel test robot 2020-10-09 1:59 ` Xin Long 2020-10-09 1:59 ` Xin Long 2020-10-08 18:29 ` [PATCHv2 net-next 05/17] sctp: create udp4 sock and add " kernel test robot 2020-10-08 18:29 ` kernel test robot 2020-10-09 1:59 ` Xin Long 2020-10-09 1:59 ` Xin Long 2020-10-08 10:01 ` [PATCHv2 net-next 04/17] udp: support sctp over udp in skb_udp_tunnel_segment Xin Long 2020-10-08 10:01 ` Xin Long 2020-10-08 10:01 ` [PATCHv2 net-next 03/17] udp: do checksum properly " Xin Long 2020-10-08 10:01 ` Xin Long 2020-10-08 12:44 ` [PATCHv2 net-next 02/17] udp6: move the mss check after udp gso tunnel processing Willem de Bruijn 2020-10-08 12:44 ` Willem de Bruijn 2020-10-09 1:48 ` Xin Long 2020-10-09 1:48 ` Xin Long 2020-10-09 13:59 ` Willem de Bruijn 2020-10-09 13:59 ` Willem de Bruijn
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=5c0e9cf835f54c11f7e3014cab926bf10a47298d.1602150362.git.lucien.xin@gmail.com \ --to=lucien.xin@gmail.com \ --cc=davem@davemloft.net \ --cc=linux-sctp@vger.kernel.org \ --cc=marcelo.leitner@gmail.com \ --cc=netdev@vger.kernel.org \ --cc=nhorman@tuxdriver.com \ --cc=tuexen@fh-muenster.de \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).