From 7cd04caf486a92c434ec2dbb98b908dede1b2a2e Mon Sep 17 00:00:00 2001 From: rjs Date: Mon, 27 Apr 2020 19:21:43 +0000 Subject: [PATCH] Do sctp_connectx() handling using ioctl() for IPv6 as well. --- sys/netinet/sctp_usrreq.c | 6 +++--- sys/netinet/sctp_var.h | 4 +++- sys/netinet6/sctp6_usrreq.c | 34 ++++++++++++++++++++++------------ 3 files changed, 28 insertions(+), 16 deletions(-) diff --git a/sys/netinet/sctp_usrreq.c b/sys/netinet/sctp_usrreq.c index c1ef60fe9fb0..a7907c7e8dbb 100644 --- a/sys/netinet/sctp_usrreq.c +++ b/sys/netinet/sctp_usrreq.c @@ -1,5 +1,5 @@ /* $KAME: sctp_usrreq.c,v 1.50 2005/06/16 20:45:29 jinmei Exp $ */ -/* $NetBSD: sctp_usrreq.c,v 1.19 2019/06/25 15:33:56 rjs Exp $ */ +/* $NetBSD: sctp_usrreq.c,v 1.20 2020/04/27 19:21:43 rjs Exp $ */ /* * Copyright (c) 2001, 2002, 2003, 2004 Cisco Systems, Inc. @@ -33,7 +33,7 @@ * SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: sctp_usrreq.c,v 1.19 2019/06/25 15:33:56 rjs Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sctp_usrreq.c,v 1.20 2020/04/27 19:21:43 rjs Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -1143,7 +1143,7 @@ sctp_count_max_addresses(struct sctp_inpcb *inp) return (cnt); } -static int +int sctp_do_connect_x(struct socket *so, struct sctp_connectx_addrs *sca, struct lwp *l, int delay) { diff --git a/sys/netinet/sctp_var.h b/sys/netinet/sctp_var.h index d3ab70452e78..7c8b9a67d7e9 100644 --- a/sys/netinet/sctp_var.h +++ b/sys/netinet/sctp_var.h @@ -1,5 +1,5 @@ /* $KAME: sctp_var.h,v 1.24 2005/03/06 16:04:19 itojun Exp $ */ -/* $NetBSD: sctp_var.h,v 1.3 2018/09/14 05:09:51 maxv Exp $ */ +/* $NetBSD: sctp_var.h,v 1.4 2020/04/27 19:21:43 rjs Exp $ */ /* * Copyright (c) 2001, 2002, 2003, 2004 Cisco Systems, Inc. @@ -161,6 +161,8 @@ void ip_2_ip6_hdr(struct ip6_hdr *, struct ip *); int sctp_bindx(struct socket *, int, struct sockaddr_storage *, int, int, struct lwp *); +int sctp_do_connect_x(struct socket *, struct sctp_connectx_addrs *, + struct lwp *, int); /* can't use sctp_assoc_t here */ int sctp_peeloff(struct socket *, struct socket *, int, vaddr_t, int *); diff --git a/sys/netinet6/sctp6_usrreq.c b/sys/netinet6/sctp6_usrreq.c index d37cc0c9fd81..8a1deae45877 100644 --- a/sys/netinet6/sctp6_usrreq.c +++ b/sys/netinet6/sctp6_usrreq.c @@ -1,5 +1,5 @@ /* $KAME: sctp6_usrreq.c,v 1.38 2005/08/24 08:08:56 suz Exp $ */ -/* $NetBSD: sctp6_usrreq.c,v 1.20 2019/06/25 15:33:56 rjs Exp $ */ +/* $NetBSD: sctp6_usrreq.c,v 1.21 2020/04/27 19:21:43 rjs Exp $ */ /* * Copyright (c) 2001, 2002, 2003, 2004 Cisco Systems, Inc. @@ -33,7 +33,7 @@ * SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: sctp6_usrreq.c,v 1.20 2019/06/25 15:33:56 rjs Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sctp6_usrreq.c,v 1.21 2020/04/27 19:21:43 rjs Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -1244,20 +1244,30 @@ sctp6_ioctl(struct socket *so, u_long cmd, void *nam, struct ifnet *ifp) int error = 0; int family; - family = so->so_proto->pr_domain->dom_family; - switch (family) { + if (cmd == SIOCCONNECTX) { + solock(so); + error = sctp_do_connect_x(so, nam, curlwp, 0); + sounlock(so); + } else if (cmd == SIOCCONNECTXDEL) { + solock(so); + error = sctp_do_connect_x(so, nam, curlwp, 1); + sounlock(so); + } else { + family = so->so_proto->pr_domain->dom_family; + switch (family) { #ifdef INET - case PF_INET: - error = in_control(so, cmd, nam, ifp); - break; + case PF_INET: + error = in_control(so, cmd, nam, ifp); + break; #endif #ifdef INET6 - case PF_INET6: - error = in6_control(so, cmd, nam, ifp); - break; + case PF_INET6: + error = in6_control(so, cmd, nam, ifp); + break; #endif - default: - error = EAFNOSUPPORT; + default: + error = EAFNOSUPPORT; + } } return (error); }