ipsec: add TCP encapsulation support (RFC 8229)
Subsystems (5)
v5 cover ipsec: add TCP encapsulation support (RFC 8229)
This patchset introduces support for TCP encapsulation of IKE and ESP messages, as defined by RFC 8229 [0]. It is an evolution of what Herbert Xu proposed in January 2018 [1] that addresses the main criticism against it, by not interfering with the TCP implementation at all. The networking stack now has infrastructure for this: TCP ULPs and Stream Parsers.
The first patches are preparation and refactoring, and the final patch adds the feature.
The main omission in this submission is IPv6 support. ESP encapsulation over UDP with IPv6 is currently not supported in the kernel either, as UDP encapsulation is aimed at NAT traversal, and NAT is not frequently used with IPv6.
Some of the code is taken directly, or slightly modified, from Herbert Xu's original submission [1]. The ULP and strparser pieces are new. This work was presented and discussed at the IPsec workshop and netdev 0x13 conference [2] in Prague, last March.
[0] https://tools.ietf.org/html/rfc8229
[1] https://patchwork.ozlabs.org/patch/859107/
[2] https://netdevconf.org/0x13/session.html?talk-ipsec-encap
Changes since v4:
- prevent combining sockmap with espintcp, as this does not work properly and I can't see a use case for it
Changes since v3:
- fix sparse warning related to RCU tag on icsk_ulp_data
Changes since v2:
- rename config option to INET_ESPINTCP and move it to net/ipv4/Kconfig (patch 6/6)
Changes since v1:
- drop patch 1, already present in the tree as commit bd95e678e0f6 ("bpf: sockmap, fix use after free from sleep in psock backlog workqueue")
- patch 1/6: fix doc error reported by kbuild test robot <[email protected]>
- patch 6/6, fix things reported by Steffen Klassert:
- remove unneeded goto and improve error handling in esp_output_tcp_finish
- clean up the ifdefs by providing dummy implementations of those functions
- fix Kconfig select, missing NET_SOCK_MSG
Sabrina Dubroca (6):
net: add queue argument to __skb_wait_for_more_packets and
__skb_{,try_}recv_datagram xfrm: introduce xfrm_trans_queue_net
xfrm: add route lookup to xfrm4_rcv_encap
esp4: prepare esp_input_done2 for non-UDP encapsulation
esp4: split esp_output_udp_encap and introduce esp_output_encap
xfrm: add espintcp (RFC 8229)
include/linux/skbuff.h | 11 +- include/net/espintcp.h | 39 +++ include/net/xfrm.h | 4 + include/uapi/linux/udp.h | 1 + net/core/datagram.c | 27 +- net/ipv4/Kconfig | 11 + net/ipv4/esp4.c | 264 ++++++++++++++++++-- net/ipv4/udp.c | 3 +- net/ipv4/xfrm4_protocol.c | 9 + net/unix/af_unix.c | 7 +- net/xfrm/Makefile | 1 + net/xfrm/espintcp.c | 509 ++++++++++++++++++++++++++++++++++++++ net/xfrm/xfrm_input.c | 21 +- net/xfrm/xfrm_policy.c | 7 + net/xfrm/xfrm_state.c | 3 + 15 files changed, 871 insertions(+), 46 deletions(-) create mode 100644 include/net/espintcp.h create mode 100644 net/xfrm/espintcp.c
Signature · 1 line
2.23.0
PATCH v5 1/6 net: add queue argument to __skb_wait_for_more_packets and __skb_{,try_}recv_datagram
This will be used by ESP over TCP to handle the queue of IKE messages.
---
v2: document the new argument to __skb_try_recv_datagram
include/linux/skbuff.h | 11 ++++++++--- net/core/datagram.c | 27 +++++++++++++++++---------- net/ipv4/udp.c | 3 ++- net/unix/af_unix.c | 7 ++++--- 4 files changed, 31 insertions(+), 17 deletions(-)
include/linux/skbuff.h +8 -3
@@ -3441,7 +3441,8 @@ static inline void skb_frag_list_init(struct sk_buff *skb)for (iter =skb_shinfo (skb)->frag_list; iter; iter = iter->next) -int __skb_wait_for_more_packets(struct sock *sk, int *err, long *timeo_p, +int __skb_wait_for_more_packets(struct sock *sk, struct sk_buff_head *queue, + int *err, long *timeo_p, const struct sk_buff *skb); struct sk_buff *__skb_try_recv_from_queue(struct sock *sk, struct sk_buff_head *queue,
@@ -3450,12 +3451,16 @@ struct sk_buff *__skb_try_recv_from_queue(struct sock *sk, struct sk_buff *skb), int *off, int *err, struct sk_buff **last); -struct sk_buff *__skb_try_recv_datagram (struct sock *sk,unsigned flags, +struct sk_buff *__skb_try_recv_datagram (struct sock *sk, +struct sk_buff_head *queue, +unsigned int flags,void (*destructor)(struct sock *sk,struct sk_buff *skb),int *off,int *err,struct sk_buff **last); -struct sk_buff *__skb_recv_datagram (struct sock *sk,unsigned flags, +struct sk_buff *__skb_recv_datagram (struct sock *sk, +struct sk_buff_head *sk_queue, +unsigned int flags,void (*destructor)(struct sock *sk,struct sk_buff *skb),int *off,int *err);
net/core/datagram.c +17 -10
@@ -84,7 +84,8 @@ static int receiver_wake_function(wait_queue_entry_t *wait, unsigned int mode, i/* * Wait for the last received packet to be different from skb */ -int __skb_wait_for_more_packets (struct sock *sk,int *err,long *timeo_p, +int __skb_wait_for_more_packets (struct sock *sk,struct sk_buff_head *queue, +int *err,long *timeo_p,const struct sk_buff *skb) {int error;
@@ -97,7 +98,7 @@ int __skb_wait_for_more_packets(struct sock *sk, int *err, long *timeo_p,if (error) goto out_err; -if (sk->sk_receive_queue.prev != skb) +if (queue->prev != skb) goto out;/* Socket shut down? */
@@ -209,6 +210,7 @@ struct sk_buff *__skb_try_recv_from_queue(struct sock *sk,/** * __skb_try_recv_datagram - Receive a datagram skbuff * @sk: socket +* @queue: socket queue from which to receive * @flags: MSG\_ flags * @destructor: invoked under the receive lock on successful dequeue * @off: an offset in bytes to peek skb from. Returns an offset
@@ -241,13 +243,14 @@ struct sk_buff *__skb_try_recv_from_queue(struct sock *sk,* quite explicitly by POSIX 1003.1g, don't change them without having * the standard around please. */ -struct sk_buff *__skb_try_recv_datagram (struct sock *sk,unsigned int flags, +struct sk_buff *__skb_try_recv_datagram (struct sock *sk, +struct sk_buff_head *queue, +unsigned int flags,void (*destructor)(struct sock *sk,struct sk_buff *skb),int *off,int *err,struct sk_buff **last) { -struct sk_buff_head *queue = &sk->sk_receive_queue;struct sk_buff *skb;unsigned long cpu_flags;/*
@@ -278,7 +281,7 @@ struct sk_buff *__skb_try_recv_datagram(struct sock *sk, unsigned int flags,break ;sk_busy_loop (sk, flags &MSG_DONTWAIT ); - }while (sk->sk_receive_queue.prev != *last); + }while (queue->prev != *last); error = -EAGAIN ;
@@ -288,7 +291,9 @@ struct sk_buff *__skb_try_recv_datagram(struct sock *sk, unsigned int flags, }EXPORT_SYMBOL (__skb_try_recv_datagram); -struct sk_buff *__skb_recv_datagram (struct sock *sk,unsigned int flags, +struct sk_buff *__skb_recv_datagram (struct sock *sk, +struct sk_buff_head *sk_queue, +unsigned int flags,void (*destructor)(struct sock *sk,struct sk_buff *skb),int *off,int *err)
@@ -299,15 +304,16 @@ struct sk_buff *__skb_recv_datagram(struct sock *sk, unsigned int flags, timeo =sock_rcvtimeo (sk, flags &MSG_DONTWAIT );do { - skb =__skb_try_recv_datagram (sk, flags, destructor, off, err, - &last); + skb =__skb_try_recv_datagram (sk, sk_queue, flags, destructor, + off, err, &last);if (skb)return skb;if (*err != -EAGAIN )break ; }while (timeo && - !__skb_wait_for_more_packets (sk, err, &timeo, last)); + !__skb_wait_for_more_packets (sk, sk_queue, err, + &timeo, last));return NULL ; }
@@ -318,7 +324,8 @@ struct sk_buff *skb_recv_datagram(struct sock *sk, unsigned int flags, {int off =0 ; -return __skb_recv_datagram (sk, flags | (noblock ?MSG_DONTWAIT :0 ), +return __skb_recv_datagram (sk, &sk->sk_receive_queue, + flags | (noblock ?MSG_DONTWAIT :0 ),NULL , &off, err); }EXPORT_SYMBOL (skb_recv_datagram);
net/ipv4/udp.c +2 -1
@@ -1677,7 +1677,8 @@ struct sk_buff *__skb_recv_udp(struct sock *sk, unsigned int flags,/* sk_queue is empty, reader_queue may contain peeked packets */ }while (timeo && - !__skb_wait_for_more_packets (sk, &error, &timeo, + !__skb_wait_for_more_packets (sk, &sk->sk_receive_queue, + &error, &timeo, (struct sk_buff *)sk_queue)); *err = error;
net/unix/af_unix.c +4 -3
@@ -2048,8 +2048,8 @@ static int unix_dgram_recvmsg(struct socket *sock, struct msghdr *msg,mutex_lock (&u->iolock); skip =sk_peek_offset (sk, flags); - skb =__skb_try_recv_datagram (sk, flags,NULL , &skip, &err, - &last); + skb =__skb_try_recv_datagram (sk, &sk->sk_receive_queue, flags, +NULL , &skip, &err, &last);if (skb)break ;
@@ -2058,7 +2058,8 @@ static int unix_dgram_recvmsg(struct socket *sock, struct msghdr *msg,if (err != -EAGAIN )break ; }while (timeo && - !__skb_wait_for_more_packets (sk, &err, &timeo, last)); + !__skb_wait_for_more_packets (sk, &sk->sk_receive_queue, + &err, &timeo, last));if (!skb) {/* implies iolock unlocked */ unix_state_lock (sk);
Signature · 1 line
2.23.0
Re: [PATCH net-next v5 1/6] net: add queue argument to __skb_wait_for_more_packets and __skb_{,try_}recv_datagram
Quoted 7 lines · Sabrina Dubroca
This will be used by ESP over TCP to handle the queue of IKE messages.
Signed-off-by Sabrina Dubroca <[email protected]>---
v2: document the new argument to__skb_try_recv_datagram
Please rebase your tree Sabrina. Some READ_ONCE() have been added lately/
Re: [PATCH net-next v5 1/6] net: add queue argument to __skb_wait_for_more_packets and __skb_{,try_}recv_datagram
Quoted 5 lines · Eric Dumazet
Quoted 2 lines · Sabrina Dubroca
This will be used by ESP over TCP to handle the queue of IKE messages.
Quoted 7 lines
Quoted 5 lines
Signed-off-by Sabrina Dubroca <[email protected]>---
v2: document the new argument to__skb_try_recv_datagramPlease rebase your tree Sabrina. Some
READ_ONCE()have been added lately/
Sorry, I messed up the subject tag, this series targets ipsec-next. The READ_ONCE() are missing there.
Signature · 1 line
Sabrina
PATCH v5 2/6 xfrm: introduce xfrm_trans_queue_net
In reply to Sabrina DubrocaThis will be used by TCP encapsulation to write packets to the encap socket without holding the user socket's lock. Without this reinjection, we're already holding the lock of the user socket, and then try to lock the encap socket as well when we enqueue the encrypted packet.
While at it, add a BUILD_BUG_ON like we usually do for skb->cb, since it's missing for struct xfrm_trans_cb.
--- include/net/xfrm.h | 3 +++ net/xfrm/xfrm_input.c | 21 +++++++++++++++++---- 2 files changed, 20 insertions(+), 4 deletions(-)
include/net/xfrm.h +3 -0
@@ -1547,6 +1547,9 @@ int __xfrm_init_state(struct xfrm_state *x, bool init_replay, bool offload);int xfrm_init_state (struct xfrm_state *x);int xfrm_input (struct sk_buff *skb,int nexthdr,__be32 spi,int encap_type);int xfrm_input_resume (struct sk_buff *skb,int nexthdr); +int xfrm_trans_queue_net (struct net *net,struct sk_buff *skb, +int (*finish)(struct net *,struct sock *, +struct sk_buff *));int xfrm_trans_queue (struct sk_buff *skb,int (*finish)(struct net *,struct sock *,struct sk_buff *));
net/xfrm/xfrm_input.c +17 -4
@@ -36,6 +36,7 @@ struct xfrm_trans_cb {#endif } header;int (*finish)(struct net *net,struct sock *sk,struct sk_buff *skb); +struct net *net; };#define XFRM_TRANS_SKB_CB (__skb) ((struct xfrm_trans_cb *)&((__skb)->cb[0]))
@@ -763,12 +764,13 @@ static void xfrm_trans_reinject(unsigned long data)skb_queue_splice_init (&trans->queue, &queue);while ((skb =__skb_dequeue (&queue))) -XFRM_TRANS_SKB_CB (skb)->finish (dev_net (skb->dev),NULL , skb); +XFRM_TRANS_SKB_CB (skb)->finish (XFRM_TRANS_SKB_CB (skb)->net, +NULL , skb); } -int xfrm_trans_queue (struct sk_buff *skb, -int (*finish)(struct net *,struct sock *, -struct sk_buff *)) +int xfrm_trans_queue_net (struct net *net,struct sk_buff *skb, +int (*finish)(struct net *,struct sock *, +struct sk_buff *)) {struct xfrm_trans_tasklet *trans;
@@ -777,11 +779,22 @@ int xfrm_trans_queue(struct sk_buff *skb,if (skb_queue_len (&trans->queue) >= netdev_max_backlog)return -ENOBUFS ; +BUILD_BUG_ON (sizeof (struct xfrm_trans_cb ) >sizeof (skb->cb)); +XFRM_TRANS_SKB_CB (skb)->finish = finish; +XFRM_TRANS_SKB_CB (skb)->net = net;__skb_queue_tail (&trans->queue, skb);tasklet_schedule (&trans->tasklet);return 0 ; } +EXPORT_SYMBOL (xfrm_trans_queue_net); + +int xfrm_trans_queue (struct sk_buff *skb, +int (*finish)(struct net *,struct sock *, +struct sk_buff *)) +{ +return xfrm_trans_queue_net (dev_net (skb->dev), skb, finish); +}EXPORT_SYMBOL (xfrm_trans_queue);void __init xfrm_input_init (void )
Signature · 1 line
2.23.0
PATCH v5 3/6 xfrm: add route lookup to xfrm4_rcv_encap
In reply to Sabrina DubrocaAt this point, with TCP encapsulation, the dst may be gone, but xfrm_input needs one.
--- net/ipv4/xfrm4_protocol.c | 9 +++++++++ 1 file changed, 9 insertions(+)
net/ipv4/xfrm4_protocol.c +9 -0
@@ -72,6 +72,14 @@ int xfrm4_rcv_encap(struct sk_buff *skb, int nexthdr, __be32 spi,if (!head) goto out; +if (!skb_dst (skb)) { +const struct iphdr *iph =ip_hdr (skb); + +if (ip_route_input_noref (skb, iph->daddr, iph->saddr, + iph->tos, skb->dev)) + goto drop; + } +for_each_protocol_rcu (*head, handler)if ((ret = handler->input_handler (skb, nexthdr, spi, encap_type)) != -EINVAL )return ret;
@@ -79,6 +87,7 @@ int xfrm4_rcv_encap(struct sk_buff *skb, int nexthdr, __be32 spi, out:icmp_send (skb,ICMP_DEST_UNREACH ,ICMP_PORT_UNREACH ,0 ); +drop:kfree_skb (skb);return 0 ; }
Signature · 1 line
2.23.0
PATCH v5 4/6 esp4: prepare esp_input_done2 for non-UDP encapsulation
In reply to Sabrina DubrocaFor espintcp encapsulation, we will need to get the source port from the TCP header instead of UDP. Introduce a variable to hold the port.
--- net/ipv4/esp4.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-)
net/ipv4/esp4.c +14 -2
@@ -601,6 +601,18 @@ int esp_input_done2(struct sk_buff *skb, int err)if (x->encap) {struct xfrm_encap_tmpl *encap = x->encap;struct udphdr *uh = (void *)(skb_network_header (skb) + ihl); +__be16 source; + +switch (x->encap->encap_type) { +case UDP_ENCAP_ESPINUDP : +case UDP_ENCAP_ESPINUDP_NON_IKE : + source = uh->source; +break ; +default : +WARN_ON_ONCE (1 ); + err = -EINVAL ; + goto out; + }/* * 1) if the NAT-T peer's IP or port changed then
@@ -609,11 +621,11 @@ int esp_input_done2(struct sk_buff *skb, int err)* SRC ports. */ if (iph->saddr != x->props.saddr.a4 || - uh->source != encap->encap_sport) { + source != encap->encap_sport) {xfrm_address_t ipaddr; ipaddr.a4 = iph->saddr; -km_new_mapping (x, &ipaddr, uh->source); +km_new_mapping (x, &ipaddr, source);/* XXX: perhaps add an extra * policy check here, to see
Signature · 1 line
2.23.0
PATCH v5 5/6 esp4: split esp_output_udp_encap and introduce esp_output_encap
In reply to Sabrina Dubroca--- net/ipv4/esp4.c | 57 ++++++++++++++++++++++++++++++++----------------- 1 file changed, 37 insertions(+), 20 deletions(-)
net/ipv4/esp4.c +37 -20
@@ -225,45 +225,62 @@ static void esp_output_fill_trailer(u8 *tail, int tfclen, int plen, __u8 proto) tail[plen -1 ] = proto; } -static int esp_output_udp_encap (struct xfrm_state *x,struct sk_buff *skb,struct esp_info *esp) +static struct ip_esp_hdr *esp_output_udp_encap (struct sk_buff *skb, +int encap_type, +struct esp_info *esp, +__be16 sport, +__be16 dport) { -int encap_type;struct udphdr *uh;__be32 *udpdata32; -__be16 sport, dport; -struct xfrm_encap_tmpl *encap = x->encap; -struct ip_esp_hdr *esph = esp->esph;unsigned int len; -spin_lock_bh (&x->lock); - sport = encap->encap_sport; - dport = encap->encap_dport; - encap_type = encap->encap_type; -spin_unlock_bh (&x->lock); - len = skb->len + esp->tailen -skb_transport_offset (skb);if (len +sizeof (struct iphdr ) >=IP_MAX_MTU ) -return -EMSGSIZE ; +return ERR_PTR (-EMSGSIZE ); - uh = (struct udphdr *)esph; + uh = (struct udphdr *)esp->esph; uh->source = sport; uh->dest = dport; uh->len =htons (len); uh->check =0 ; + *skb_mac_header (skb) =IPPROTO_UDP ; + +if (encap_type ==UDP_ENCAP_ESPINUDP_NON_IKE ) { + udpdata32 = (__be32 *)(uh +1 ); + udpdata32[0 ] = udpdata32[1 ] =0 ; +return (struct ip_esp_hdr *)(udpdata32 +2 ); + } + +return (struct ip_esp_hdr *)(uh +1 ); +} + +static int esp_output_encap (struct xfrm_state *x,struct sk_buff *skb, +struct esp_info *esp) +{ +struct xfrm_encap_tmpl *encap = x->encap; +struct ip_esp_hdr *esph; +__be16 sport, dport; +int encap_type; + +spin_lock_bh (&x->lock); + sport = encap->encap_sport; + dport = encap->encap_dport; + encap_type = encap->encap_type; +spin_unlock_bh (&x->lock); +switch (encap_type) {default :case UDP_ENCAP_ESPINUDP : - esph = (struct ip_esp_hdr *)(uh +1 ); -break ;case UDP_ENCAP_ESPINUDP_NON_IKE : - udpdata32 = (__be32 *)(uh +1 ); - udpdata32[0 ] = udpdata32[1 ] =0 ; - esph = (struct ip_esp_hdr *)(udpdata32 +2 ); + esph =esp_output_udp_encap (skb, encap_type, esp, sport, dport);break ; } - *skb_mac_header (skb) =IPPROTO_UDP ; +if (IS_ERR (esph)) +return PTR_ERR (esph); + esp->esph = esph;return 0 ;
@@ -281,7 +298,7 @@ int esp_output_head(struct xfrm_state *x, struct sk_buff *skb, struct esp_info */* this is non-NULL only with UDP Encapsulation */ if (x->encap) { -int err =esp_output_udp_encap (x, skb, esp); +int err =esp_output_encap (x, skb, esp);if (err <0 )return err;
Signature · 1 line
2.23.0
PATCH v5 6/6 xfrm: add espintcp (RFC 8229)
In reply to Sabrina DubrocaTCP encapsulation of IKE and IPsec messages (RFC 8229) is implemented as a TCP ULP, overriding in particular the sendmsg and recvmsg operations. A Stream Parser is used to extract messages out of the TCP stream using the first 2 bytes as length marker. Received IKE messages are put on "ike_queue", waiting to be dequeued by the custom recvmsg implementation. Received ESP messages are sent to XFRM, like with UDP encapsulation.
Some of this code is taken from the original submission by Herbert Xu. Currently, only IPv4 is supported, like for UDP encapsulation.
---
v5: prevent enabling espintcp if the socket is already part of a
sockmap
v4: fix sparse warnings related to RCU with icsk_ulp_data
- use rcu_assign_pointer in espintcp_init_sk
- use __force cast in espintcp_getctx
v3: rename config option to INET_ESPINTCP and move it to net/ipv4/Kconfig v2:
- remove unneeded goto and improve error handling in esp_output_tcp_finish
- clean up the ifdefs by providing dummy implementations of those functions
- fix Kconfig select, missing NET_SOCK_MSG
include/net/espintcp.h | 39 +++ include/net/xfrm.h | 1 + include/uapi/linux/udp.h | 1 + net/ipv4/Kconfig | 11 + net/ipv4/esp4.c | 191 ++++++++++++++- net/xfrm/Makefile | 1 + net/xfrm/espintcp.c | 509 +++++++++++++++++++++++++++++++++++++++ net/xfrm/xfrm_policy.c | 7 + net/xfrm/xfrm_state.c | 3 + 9 files changed, 760 insertions(+), 3 deletions(-) create mode 100644 include/net/espintcp.h create mode 100644 net/xfrm/espintcp.c
include/net/espintcp.h new file +39 -0
@@ -0,0 +1,39 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _NET_ESPINTCP_H +#define _NET_ESPINTCP_H + +#include <net/strparser.h> +#include <linux/skmsg.h> + +void __init espintcp_init (void ); + +int espintcp_push_skb (struct sock *sk,struct sk_buff *skb); +int espintcp_queue_out (struct sock *sk,struct sk_buff *skb); +bool tcp_is_ulp_esp (struct sock *sk); + +struct espintcp_msg { +struct sk_buff *skb; +struct sk_msg skmsg; +int offset; +int len; +}; + +struct espintcp_ctx { +struct strparser strp; +struct sk_buff_head ike_queue; +struct sk_buff_head out_queue; +struct espintcp_msg partial; +void (*saved_data_ready)(struct sock *sk); +void (*saved_write_space)(struct sock *sk); +struct work_struct work; +bool tx_running; +}; + +static inline struct espintcp_ctx *espintcp_getctx (const struct sock *sk) +{ +struct inet_connection_sock *icsk =inet_csk (sk); + +/* RCU is only needed for diag */ +return (__force void *)icsk->icsk_ulp_data; +} +#endif
include/net/xfrm.h +1 -0
@@ -193,6 +193,7 @@ struct xfrm_state {/* Data for encapsulator */ struct xfrm_encap_tmpl *encap; +struct sock __rcu *encap_sk;/* Data for care-of address */ xfrm_address_t *coaddr;
include/uapi/linux/udp.h +1 -0
@@ -42,5 +42,6 @@ struct udphdr {#define UDP_ENCAP_GTP0 4/* GSM TS 09.60 */ #define UDP_ENCAP_GTP1U 5/* 3GPP TS 29.060 */ #define UDP_ENCAP_RXRPC 6 +#define TCP_ENCAP_ESPINTCP 7/* Yikes, this is really xfrm encap types. */ #endif /* _UAPI_LINUX_UDP_H */
net/ipv4/Kconfig +11 -0
@@ -378,6 +378,17 @@ config INET_ESP_OFFLOAD If unsure, say N. +config INET_ESPINTCP + bool "IP: ESP in TCP encapsulation (RFC 8229)" + depends on XFRM && INET_ESP + select STREAM_PARSER + select NET_SOCK_MSG + help + Support for RFC 8229 encapsulation of ESP and IKE over + TCP/IPv4 sockets. + + If unsure, say N. + config INET_IPCOMP tristate "IP: IPComp transformation" select INET_XFRM_TUNNEL
net/ipv4/esp4.c +188 -3
255 lines not on this page · raw message
net/xfrm/Makefile +1 -0
@@ -11,3 +11,4 @@ obj-$(CONFIG_XFRM_ALGO) += xfrm_algo.o obj-$(CONFIG_XFRM_USER) += xfrm_user.o obj-$(CONFIG_XFRM_IPCOMP) += xfrm_ipcomp.o obj-$(CONFIG_XFRM_INTERFACE) += xfrm_interface.o +obj-$(CONFIG_INET_ESPINTCP) += espintcp.o
net/xfrm/espintcp.c new file +509 -0
509 lines not on this page · raw message
net/xfrm/xfrm_policy.c +7 -0
@@ -39,6 +39,9 @@#ifdef CONFIG_XFRM_STATISTICS #include <net/snmp.h> #endif +#ifdef CONFIG_INET_ESPINTCP +#include <net/espintcp.h> +#endif #include "xfrm_hash.h"
@@ -4157,6 +4160,10 @@ void __init xfrm_init(void)seqcount_init (&xfrm_policy_hash_generation);xfrm_input_init (); +#ifdef CONFIG_INET_ESPINTCP +espintcp_init (); +#endif +RCU_INIT_POINTER (xfrm_if_cb,NULL );synchronize_rcu (); }
net/xfrm/xfrm_state.c +3 -0
@@ -668,6 +668,9 @@ int __xfrm_state_delete(struct xfrm_state *x) net->xfrm.state_num--;spin_unlock (&net->xfrm.xfrm_state_lock); +if (x->encap_sk) +sock_put (rcu_dereference_raw (x->encap_sk)); +xfrm_dev_state_delete (x);/* All xfrm_state objects are created by xfrm_state_alloc.
Signature · 1 line
2.23.0
From: Sabrina Dubroca <[email protected]>
Date: Tue, 12 Nov 2019 16:18:37 +0100
Quoted 15 lines
This patchset introduces support for TCP encapsulation of IKE and ESP messages, as defined by RFC 8229 [0]. It is an evolution of what Herbert Xu proposed in January 2018 [1] that addresses the main criticism against it, by not interfering with the TCP implementation at all. The networking stack now has infrastructure for this: TCP ULPs and Stream Parsers.
The first patches are preparation and refactoring, and the final patch adds the feature.
The main omission in this submission is IPv6 support. ESP encapsulation over UDP with IPv6 is currently not supported in the kernel either, as UDP encapsulation is aimed at NAT traversal, and NAT is not frequently used with IPv6.
Quoted 8 lines
Some of the code is taken directly, or slightly modified, from Herbert Xu's original submission [1]. The ULP and strparser pieces are new. This work was presented and discussed at the IPsec workshop and netdev
0x13conference [2] in Prague, last March.[0] https://tools.ietf.org/html/rfc8229
[1] https://patchwork.ozlabs.org/patch/859107/
[2] https://netdevconf.org/0x13/session.html?talk-ipsec-encap
...
This looks generally fine to me, and I assume Steffen will pick this up and integrate it into his ipsec-next tree.
For the series:
Steffen Klassert
maintainerQuoted 15 lines · Sabrina Dubroca
This patchset introduces support for TCP encapsulation of IKE and ESP messages, as defined by RFC 8229 [0]. It is an evolution of what Herbert Xu proposed in January 2018 [1] that addresses the main criticism against it, by not interfering with the TCP implementation at all. The networking stack now has infrastructure for this: TCP ULPs and Stream Parsers.
The first patches are preparation and refactoring, and the final patch adds the feature.
The main omission in this submission is IPv6 support. ESP encapsulation over UDP with IPv6 is currently not supported in the kernel either, as UDP encapsulation is aimed at NAT traversal, and NAT is not frequently used with IPv6.
Quoted 8 lines
Some of the code is taken directly, or slightly modified, from Herbert Xu's original submission [1]. The ULP and strparser pieces are new. This work was presented and discussed at the IPsec workshop and netdev
0x13conference [2] in Prague, last March.[0] https://tools.ietf.org/html/rfc8229
[1] https://patchwork.ozlabs.org/patch/859107/
[2] https://netdevconf.org/0x13/session.html?talk-ipsec-encap
The patchset does not apply anymore after updating the ipsec-next tree. Can you respin once again?
I'll apply it right away then.
Thanks!
Quoted 25 lines · Steffen Klassert
Quoted 15 lines · Sabrina Dubroca
This patchset introduces support for TCP encapsulation of IKE and ESP messages, as defined by RFC 8229 [0]. It is an evolution of what Herbert Xu proposed in January 2018 [1] that addresses the main criticism against it, by not interfering with the TCP implementation at all. The networking stack now has infrastructure for this: TCP ULPs and Stream Parsers.
The first patches are preparation and refactoring, and the final patch adds the feature.
The main omission in this submission is IPv6 support. ESP encapsulation over UDP with IPv6 is currently not supported in the kernel either, as UDP encapsulation is aimed at NAT traversal, and NAT is not frequently used with IPv6.
Quoted 8 lines
Some of the code is taken directly, or slightly modified, from Herbert Xu's original submission [1]. The ULP and strparser pieces are new. This work was presented and discussed at the IPsec workshop and netdev
0x13conference [2] in Prague, last March.[0] https://tools.ietf.org/html/rfc8229
[1] https://patchwork.ozlabs.org/patch/859107/
[2] https://netdevconf.org/0x13/session.html?talk-ipsec-encap
Quoted 6 lines
The patchset does not apply anymore after updating the ipsec-next tree. Can you respin once again?
I'll apply it right away then.
Thanks!
Ah, yes, that's the change Eric mentioned last week. I'll repost in a bit, thanks.
Signature · 1 line
Sabrina