From owner-dev-commits-src-branches@freebsd.org Tue Mar 9 08:54:01 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 5012756FAF9; Tue, 9 Mar 2021 08:54:01 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Dvpsj1t3cz3Lh7; Tue, 9 Mar 2021 08:54:01 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 32FDF191B5; Tue, 9 Mar 2021 08:54:01 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1298s1rf057234; Tue, 9 Mar 2021 08:54:01 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1298s10E057232; Tue, 9 Mar 2021 08:54:01 GMT (envelope-from git) Date: Tue, 9 Mar 2021 08:54:01 GMT Message-Id: <202103090854.1298s10E057232@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: "Andrey V. Elsukov" Subject: git: fb827e006cec - stable/12 - ipfw: add IPv6 support for sockarg opcode. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: ae X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: fb827e006cec095cbbec1811c9fb27722e76c6f6 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 09 Mar 2021 08:54:01 -0000 The branch stable/12 has been updated by ae: URL: https://cgit.FreeBSD.org/src/commit/?id=fb827e006cec095cbbec1811c9fb27722e76c6f6 commit fb827e006cec095cbbec1811c9fb27722e76c6f6 Author: Andrey V. Elsukov AuthorDate: 2021-03-02 09:45:59 +0000 Commit: Andrey V. Elsukov CommitDate: 2021-03-09 08:52:19 +0000 ipfw: add IPv6 support for sockarg opcode. Sponsored by: Yandex LLC (cherry picked from commit a9f7eba9597189c0e438f6986067d31dca1c53b0) --- sys/netpfil/ipfw/ip_fw2.c | 44 ++++++++++++++++++++++++++------------------ 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/sys/netpfil/ipfw/ip_fw2.c b/sys/netpfil/ipfw/ip_fw2.c index f639a3bfabbd..9d60b446dc73 100644 --- a/sys/netpfil/ipfw/ip_fw2.c +++ b/sys/netpfil/ipfw/ip_fw2.c @@ -2587,9 +2587,7 @@ do { \ #ifndef USERSPACE /* not supported in userspace */ struct inpcb *inp = args->inp; struct inpcbinfo *pi; - - if (is_ipv6) /* XXX can we remove this ? */ - break; + bool inp_locked = false; if (proto == IPPROTO_TCP) pi = &V_tcbinfo; @@ -2605,27 +2603,37 @@ do { \ * certainly be inp_user_cookie? */ - /* For incoming packet, lookup up the - inpcb using the src/dest ip/port tuple */ - if (inp == NULL) { - inp = in_pcblookup(pi, - src_ip, htons(src_port), - dst_ip, htons(dst_port), - INPLOOKUP_RLOCKPCB, NULL); - if (inp != NULL) { - tablearg = - inp->inp_socket->so_user_cookie; - if (tablearg) - match = 1; - INP_RUNLOCK(inp); - } - } else { + /* + * For incoming packet lookup the inpcb + * using the src/dest ip/port tuple. + */ + if (is_ipv4 && inp == NULL) { + inp = in_pcblookup(pi, + src_ip, htons(src_port), + dst_ip, htons(dst_port), + INPLOOKUP_RLOCKPCB, NULL); + inp_locked = true; + } +#ifdef INET6 + if (is_ipv6 && inp == NULL) { + inp = in6_pcblookup(pi, + &args->f_id.src_ip6, + htons(src_port), + &args->f_id.dst_ip6, + htons(dst_port), + INPLOOKUP_RLOCKPCB, NULL); + inp_locked = true; + } +#endif /* INET6 */ + if (inp != NULL) { if (inp->inp_socket) { tablearg = inp->inp_socket->so_user_cookie; if (tablearg) match = 1; } + if (inp_locked) + INP_RUNLOCK(inp); } #endif /* !USERSPACE */ break;