diff options
author | melifaro <melifaro@FreeBSD.org> | 2015-09-18 17:29:24 +0000 |
---|---|---|
committer | melifaro <melifaro@FreeBSD.org> | 2015-09-18 17:29:24 +0000 |
commit | 5496fd3096bf187ed2221f8f0290f9f119b06208 (patch) | |
tree | 7ab3e012c4c9d531d96fb628c7a3e79f93933434 /sys | |
parent | 26a0cf375aceedb2911b79b762cbc4f28510040a (diff) | |
download | FreeBSD-src-5496fd3096bf187ed2221f8f0290f9f119b06208.zip FreeBSD-src-5496fd3096bf187ed2221f8f0290f9f119b06208.tar.gz |
MFC r266310
Fix wrong formatting of 0.0.0.0/X table records in ipfw(8).
Add `flags` u16 field to the hole in ipfw_table_xentry structure.
Kernel has been guessing address family for supplied record based
on xent length size.
Userland, however, has been getting fixed-size ipfw_table_xentry structures
guessing address family by checking address by IN6_IS_ADDR_V4COMPAT().
Fix this behavior by providing specific IPFW_TCF_INET flag for IPv4 records.
PR: bin/189471,kern/200169
Diffstat (limited to 'sys')
-rw-r--r-- | sys/netinet/ip_fw.h | 2 | ||||
-rw-r--r-- | sys/netpfil/ipfw/ip_fw_table.c | 1 |
2 files changed, 3 insertions, 0 deletions
diff --git a/sys/netinet/ip_fw.h b/sys/netinet/ip_fw.h index 14b08f5..dae8cc0 100644 --- a/sys/netinet/ip_fw.h +++ b/sys/netinet/ip_fw.h @@ -614,6 +614,7 @@ typedef struct _ipfw_table_xentry { uint8_t type; /* entry type */ uint8_t masklen; /* mask length */ uint16_t tbl; /* table number */ + uint16_t flags; /* record flags */ uint32_t value; /* value */ union { /* Longest field needs to be aligned by 4-byte boundary */ @@ -621,6 +622,7 @@ typedef struct _ipfw_table_xentry { char iface[IF_NAMESIZE]; /* interface name */ } k; } ipfw_table_xentry; +#define IPFW_TCF_INET 0x01 /* CIDR flags: IPv4 record */ typedef struct _ipfw_table { u_int32_t size; /* size of entries in bytes */ diff --git a/sys/netpfil/ipfw/ip_fw_table.c b/sys/netpfil/ipfw/ip_fw_table.c index 31eebfe..760a10c 100644 --- a/sys/netpfil/ipfw/ip_fw_table.c +++ b/sys/netpfil/ipfw/ip_fw_table.c @@ -697,6 +697,7 @@ dump_table_xentry_base(struct radix_node *rn, void *arg) xent->masklen = 33 - ffs(ntohl(n->mask.sin_addr.s_addr)); /* Save IPv4 address as deprecated IPv6 compatible */ xent->k.addr6.s6_addr32[3] = n->addr.sin_addr.s_addr; + xent->flags = IPFW_TCF_INET; xent->value = n->value; tbl->cnt++; return (0); |