summaryrefslogtreecommitdiffstats
path: root/sys/netinet
diff options
context:
space:
mode:
authorluigi <luigi@FreeBSD.org>2009-06-05 16:16:07 +0000
committerluigi <luigi@FreeBSD.org>2009-06-05 16:16:07 +0000
commit78a4bbf2875db443e6d62f814cfa0932be524a77 (patch)
treecc9a1d6bcbb36b2c50e8350ac7660df15d0ada25 /sys/netinet
parente2c9e0cf9e1bbc082567007c180519f2b1079d8b (diff)
downloadFreeBSD-src-78a4bbf2875db443e6d62f814cfa0932be524a77.zip
FreeBSD-src-78a4bbf2875db443e6d62f814cfa0932be524a77.tar.gz
Several ipfw options and actions use a 16-bit argument to indicate
pipes, queues, tags, rule numbers and so on. These are all different namespaces, and the only thing they have in common is the fact they use a 16-bit slot to represent the argument. There is some confusion in the code, mostly for historical reasons, on how the values 0 and 65535 should be used. At the moment, 0 is forbidden almost everywhere, while 65535 is used to represent a 'tablearg' argument, i.e. the result of the most recent table() lookup. For now, try to use explicit constants for the min and max allowed values, and do not overload the default rule number for that. Also, make the MTAG_IPFW declaration only visible to the kernel. NOTE: I think the issue needs to be revisited before 8.0 is out: the 2^16 namespace limit for rule numbers and pipe/queue is annoying, and we can easily bump the limit to 2^32 which gives a lot more flexibility in partitioning the namespace. MFC after: 5 days
Diffstat (limited to 'sys/netinet')
-rw-r--r--sys/netinet/ip_fw.h22
1 files changed, 17 insertions, 5 deletions
diff --git a/sys/netinet/ip_fw.h b/sys/netinet/ip_fw.h
index a137cee..5602e9e 100644
--- a/sys/netinet/ip_fw.h
+++ b/sys/netinet/ip_fw.h
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 2002 Luigi Rizzo, Universita` di Pisa
+ * Copyright (c) 2002-2009 Luigi Rizzo, Universita` di Pisa
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -43,6 +43,20 @@
#define IPFW_TABLES_MAX 128
/*
+ * Most commands (queue, pipe, tag, untag, limit...) can have a 16-bit
+ * argument between 1 and 65534. The value 0 is unused, the value
+ * 65535 (IP_FW_TABLEARG) is used to represent 'tablearg', i.e. the
+ * can be 1..65534, or 65535 to indicate the use of a 'tablearg'
+ * result of the most recent table() lookup.
+ * Note that 16bit is only a historical limit, resulting from
+ * the use of a 16-bit fields for that value. In reality, we can have
+ * 2^32 pipes, queues, tag values and so on, and use 0 as a tablearg.
+ */
+#define IPFW_ARG_MIN 1
+#define IPFW_ARG_MAX 65534
+#define IP_FW_TABLEARG 65535 /* XXX should use 0 */
+
+/*
* The kernel representation of ipfw rules is made of a list of
* 'instructions' (for all practical purposes equivalent to BPF
* instructions), which specify which fields of the packet
@@ -239,8 +253,6 @@ typedef struct _ipfw_insn { /* template for instructions */
*/
#define F_INSN_SIZE(t) ((sizeof (t))/sizeof(u_int32_t))
-#define MTAG_IPFW 1148380143 /* IPFW-tagged cookie */
-
/*
* This is used to store an array of 16-bit entries (ports etc.)
*/
@@ -558,13 +570,13 @@ typedef struct _ipfw_table {
ipfw_table_entry ent[0]; /* entries */
} ipfw_table;
-#define IP_FW_TABLEARG 65535
-
/*
* Main firewall chains definitions and global var's definitions.
*/
#ifdef _KERNEL
+#define MTAG_IPFW 1148380143 /* IPFW-tagged cookie */
+
/* Return values from ipfw_chk() */
enum {
IP_FW_PASS = 0,
OpenPOWER on IntegriCloud