Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 21 Oct 2018 15:10:59 +0000 (UTC)
From:      "Andrey V. Elsukov" <ae@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r339539 - in head: sbin/ipfw sys/netinet
Message-ID:  <201810211510.w9LFAxJq089697@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ae
Date: Sun Oct 21 15:10:59 2018
New Revision: 339539
URL: https://svnweb.freebsd.org/changeset/base/339539

Log:
  Add IPFW_RULE_JUSTOPTS flag, that is used by ipfw(8) to mark rule,
  that was added using "new rule format". And then, when the kernel
  returns rule with this flag, ipfw(8) can correctly show it.
  
  Reported by:	lev
  MFC after:	3 weeks
  Sponsored by:	Yandex LLC
  Differential Revision:	https://reviews.freebsd.org/D17373

Modified:
  head/sbin/ipfw/ipfw2.c
  head/sys/netinet/ip_fw.h

Modified: head/sbin/ipfw/ipfw2.c
==============================================================================
--- head/sbin/ipfw/ipfw2.c	Sun Oct 21 15:09:42 2018	(r339538)
+++ head/sbin/ipfw/ipfw2.c	Sun Oct 21 15:10:59 2018	(r339539)
@@ -2207,6 +2207,12 @@ show_static_rule(struct cmdline_opts *co, struct forma
 	 */
 	if (co->comment_only != 0)
 		goto end;
+
+	if (rule->flags & IPFW_RULE_JUSTOPTS) {
+		state.flags |= HAVE_PROTO | HAVE_SRCIP | HAVE_DSTIP;
+		goto justopts;
+	}
+
 	print_proto(bp, fo, &state);
 
 	/* Print source */
@@ -2219,6 +2225,7 @@ show_static_rule(struct cmdline_opts *co, struct forma
 	print_address(bp, fo, &state, dst_opcodes, nitems(dst_opcodes),
 	    O_IP_DSTPORT, HAVE_DSTIP);
 
+justopts:
 	/* Print the rest of options */
 	while (print_opcode(bp, fo, &state, -1))
 		;
@@ -4340,8 +4347,10 @@ chkarg:
 		}
 	} else if (first_cmd != cmd) {
 		errx(EX_DATAERR, "invalid protocol ``%s''", *av);
-	} else
+	} else {
+		rule->flags |= IPFW_RULE_JUSTOPTS;
 		goto read_options;
+	}
     OR_BLOCK(get_proto);
 
 	/*

Modified: head/sys/netinet/ip_fw.h
==============================================================================
--- head/sys/netinet/ip_fw.h	Sun Oct 21 15:09:42 2018	(r339538)
+++ head/sys/netinet/ip_fw.h	Sun Oct 21 15:10:59 2018	(r339539)
@@ -615,6 +615,7 @@ struct ip_fw_rule {
 	ipfw_insn	cmd[1];		/* storage for commands		*/
 };
 #define	IPFW_RULE_NOOPT		0x01	/* Has no options in body	*/
+#define	IPFW_RULE_JUSTOPTS	0x02	/* new format of rule body	*/
 
 /* Unaligned version */
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201810211510.w9LFAxJq089697>