From nobody Thu Feb 13 12:39:07 2025 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4YtvrD4mzrz5nR9K; Thu, 13 Feb 2025 12:39:08 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4YtvrC6zh7z3g4j; Thu, 13 Feb 2025 12:39:07 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1739450348; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=IFNQ3mi/UfGJ+gZJqVJOLzN1fiHnc5DouFcbr5CQkx4=; b=kw+EeJ/sNxpCS3AZEnyLHCL2pokiMNI7BjSqLubBbuGTmc4DsWyjrByiSNLmn+mH7Vr0Ya Qyk9DgOWWv/9hVxetS1lRpBakLgoqpHNrIahzc4QKv9rKeN45McqtcMEwWC5i0iNya2nbn Nw/zJ/iVo0OKtV4V85JOzkfT9Lrs4wXTUkeHEdbkHP5RhfS8nutl8d587z6PPU1qZpiD7c MY2DzXVO5OyN/wkp5gXMRuSeNdQZugxj6okwqjS7kgJ9zHcWz1GCTlZPZXlbZ7BvL9+gfh 98jwe3Zf1Bycw0Ti0fX3xmGAlq8wACn9x4fOwJy1LpMw+MNgtSFK8Hpr1I/Udw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1739450348; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=IFNQ3mi/UfGJ+gZJqVJOLzN1fiHnc5DouFcbr5CQkx4=; b=ctPnk6QdghUSp6ZzlFrVOOdk/HilsvDrXK854fQLHpHqi6yvFblWumh3GzAhi/d5JUh3Da OzQg9ctyhbIN+XS+e7aj2Gemi6yVqBQYl/soYlUAjjwEhfnnJFZoTVwruBttckq5eocsOD atyGisquMxhEDelbLPRiGNO7YR2d3pgNM4ncI5ejaOnoN72cNDzztTKXXY5l5h98x0sBqn Lj/6QkjqtxIoRgVeMSDOkkleQTReD2iPUapZFe0tScKY8KUKH1oe4SeMJkV6Ue/vyjQ1HL Uj7+YGRNA2Z8wvKDHRxj0aunuxJULhIekosbYbqWIhVs5CNnaVF+DakGNIT58A== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1739450348; a=rsa-sha256; cv=none; b=qTBxr82I/gZLVXdra6m5AQTo7GJ1x+JC1FIXNCt7WChcsJr3V+kx4gAHrRClJ+5zgojf5r BYXCyNF7JTlriqOudezXYANwEMKy0Mnec9ErNnOH0OdTLd4s36fJ0OIQUExmqScRv97YJM guybB0J7iE9+rAwQyHZJob7Z6iMTEO+n+yLfj/ZoQceo3vaFpsHZ05+O+DMtCLZSEKJLzv lBYzRiqCZkVDmZtWZQqy1Y9gDd8ZUuv/xefqk2LhtrsZMJp589B76SVdtK9wseQTYK5/BN Sd26qTsZ7o/xxYPdkAZS310VhimjpRoTs4y7orgh5edozswe9txUblb0bmWT8w== ARC-Authentication-Results: i=1; mx1.freebsd.org; none 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 4YtvrC5GQfzlyf; Thu, 13 Feb 2025 12:39:07 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 51DCd7jx075657; Thu, 13 Feb 2025 12:39:07 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 51DCd7Iv075654; Thu, 13 Feb 2025 12:39:07 GMT (envelope-from git) Date: Thu, 13 Feb 2025 12:39:07 GMT Message-Id: <202502131239.51DCd7Iv075654@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kristof Provost Subject: git: 71594e3235f2 - main - pf: support "!received-on " List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 71594e3235f21746fbc6c0b12ad70409db18a46b Auto-Submitted: auto-generated The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=71594e3235f21746fbc6c0b12ad70409db18a46b commit 71594e3235f21746fbc6c0b12ad70409db18a46b Author: Kristof Provost AuthorDate: 2025-02-10 16:33:57 +0000 Commit: Kristof Provost CommitDate: 2025-02-13 12:38:44 +0000 pf: support "!received-on " ok dlg benno Obtained from: OpenBSD, henning , 7d0482a910 Sponsored by: Rubicon Communications, LLC ("Netgate") --- lib/libpfctl/libpfctl.c | 2 ++ lib/libpfctl/libpfctl.h | 1 + sbin/pfctl/parse.y | 6 ++++-- sbin/pfctl/pfctl_parser.c | 3 ++- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/libpfctl/libpfctl.c b/lib/libpfctl/libpfctl.c index 8569d691773c..fe63c91c1174 100644 --- a/lib/libpfctl/libpfctl.c +++ b/lib/libpfctl/libpfctl.c @@ -1255,6 +1255,7 @@ snl_add_msg_attr_pf_rule(struct snl_writer *nw, uint32_t type, const struct pfct snl_add_msg_attr_uid(nw, PF_RT_UID, &r->uid); snl_add_msg_attr_uid(nw, PF_RT_GID, (const struct pf_rule_uid *)&r->gid); snl_add_msg_attr_string(nw, PF_RT_RCV_IFNAME, r->rcv_ifname); + snl_add_msg_attr_bool(nw, PF_RT_RCV_IFNOT, r->rcvifnot); snl_add_msg_attr_u32(nw, PF_RT_RULE_FLAG, r->rule_flag); snl_add_msg_attr_u8(nw, PF_RT_ACTION, r->action); @@ -1663,6 +1664,7 @@ static struct snl_attr_parser ap_getrule[] = { { .type = PF_RT_RPOOL_NAT, .off = _OUT(r.nat), .arg = &pool_parser, .cb = snl_attr_get_nested }, { .type = PF_RT_NAF, .off = _OUT(r.naf), .cb = snl_attr_get_uint8 }, { .type = PF_RT_RPOOL_RT, .off = _OUT(r.route), .arg = &pool_parser, .cb = snl_attr_get_nested }, + { .type = PF_RT_RCV_IFNOT, .off = _OUT(r.rcvifnot),.cb = snl_attr_get_bool }, }; #undef _OUT SNL_DECLARE_PARSER(getrule_parser, struct genlmsghdr, snl_f_p_empty, ap_getrule); diff --git a/lib/libpfctl/libpfctl.h b/lib/libpfctl/libpfctl.h index d5d0a43f90a3..e1af4b5e97ff 100644 --- a/lib/libpfctl/libpfctl.h +++ b/lib/libpfctl/libpfctl.h @@ -227,6 +227,7 @@ struct pfctl_rule { struct pf_rule_uid uid; struct pf_rule_gid gid; char rcv_ifname[IFNAMSIZ]; + bool rcvifnot; uint32_t rule_flag; uint8_t action; diff --git a/sbin/pfctl/parse.y b/sbin/pfctl/parse.y index 40d116fe1a50..981039f4124c 100644 --- a/sbin/pfctl/parse.y +++ b/sbin/pfctl/parse.y @@ -2974,12 +2974,13 @@ filter_opt : USER uids { filter_opts.match_tag = $3; filter_opts.match_tag_not = $1; } - | RECEIVEDON if_item { + | not RECEIVEDON if_item { if (filter_opts.rcv) { yyerror("cannot respecify received-on"); YYERROR; } - filter_opts.rcv = $2; + filter_opts.rcv = $3; + filter_opts.rcv->not = $1; } | PROBABILITY probability { double p; @@ -6279,6 +6280,7 @@ expand_rule(struct pfctl_rule *r, if (rcv) { strlcpy(r->rcv_ifname, rcv->ifname, sizeof(r->rcv_ifname)); + r->rcvifnot = rcv->not; } r->type = icmp_type->type; r->code = icmp_type->code; diff --git a/sbin/pfctl/pfctl_parser.c b/sbin/pfctl/pfctl_parser.c index d1e0b4e99940..7a6d2fc8eed5 100644 --- a/sbin/pfctl/pfctl_parser.c +++ b/sbin/pfctl/pfctl_parser.c @@ -961,7 +961,8 @@ print_rule(struct pfctl_rule *r, const char *anchor_call, int verbose, int numer print_fromto(&r->src, r->os_fingerprint, &r->dst, r->af, r->proto, verbose, numeric); if (r->rcv_ifname[0]) - printf(" received-on %s", r->rcv_ifname); + printf(" %sreceived-on %s", r->rcvifnot ? "!" : "", + r->rcv_ifname); if (r->uid.op) print_ugid(r->uid.op, r->uid.uid[0], r->uid.uid[1], "user", UID_MAX);