IPFW I think I found a minor ipwf bug - what to do with it? Is it worth to be reported?

Dear community,

I have read How to Submit a Bug Report and no idea if this is worth reporting or which category to choose or if this is worth anyone's time who would receive a bug report. But I can reproduce it so I thought I post here.

I'm running FreeBSD 14.0-RELEASE-p6 (coming from 13, I upgraded from there) with csh as root shell where I ran the below sequence of ipfw commands.

Code:
sysctl net.inet.ip.fw.tables_sets=1
ipfw set 0 table ADDR add anything
ipfw set 0 table all list
ipfw set 0 table ADDR add anything 255.255.255.255
ipfw set 0 table ADDR flush
ipfw set 0 table ADDR add anything 255.255.255.255
ipfw set 0 table all list
ipfw set 0 table ADDR flush
ipfw set 0 table ADDR add anything 255.255.255.255
ipfw set 0 table ADDR flush
ipfw set 0 table ADDR add anything 255.255.255.255
ipfw set 0 table ADDR add whatever
ipfw set 0 table ADDR add 192.0.2.1/32 em0
ipfw set 0 table ADDR add 192.0.2.1/32 em0.100
ipfw table ADDR add 192.0.2.1 re0
ipfw table ADDR add re0
ipfw table all list
ipfw table all flush
ipfw table ADDR add re0
ipfw table all detail
ipfw table all flush
ipfw table all destroy
ipfw table ADDR create type addr
ipfw table ADDR add re0
ipfw set 23 table ADDR add dead:beef:c0fe:dead:beef:c0fe:fe80:1234/56 0 192.0.2.1/1 0xffffffff 192.0.2.2 255.255.255.255
ipfw table all list
ipfw -i table all list
ipfw table all destroy
ipfw table all list
ipfw table DOESNOTEXISTACTUALLY add wlan0
ipfw table all list
ipfw table all info
ipfw add 65046 set 5 deny ip from table\(twentythree\) to any
ipfw table all info
ipfw set 23 table ADDR create type addr
ipfw set 23 table IFACE create type iface
ipfw set 23 table NUMBER create type number
ipfw set 23 table FLOW create type flow
ipfw set 23 table MAC create type mac
ipfw table all list
ipfw set 23 add table IFACE add 4242
ipfw set 23 table IFACE add 4242
ipfw set 23 table IFACE add anything
ipfw set 23 table IFACE add anything no_controls_here
ipfw set 23 table IFACE add anything no-controls-here
ipfw set 23 table IFACE add anything controls?here
ipfw set 23 table IFACE add anything .1
ipfw set 23 table IFACE add anything l.1
ipfw set 23 table IFACE add anything wer.1
ipfw set 23 table IFACE add anything wer0.1
ipfw set 23 table IFACE add anything igb0.123
ipfw set 23 table IFACE add anything
ipfw set 23 table IFACE add asdf?
ipfw set 23 table IFACE add asdf
ipfw set 23 table IFACE add asdf32
ipfw set 23 table IFACE add asdf.32
ipfw set 23 table IFACE add asdf..32
ipfw set 23 table IFACE add asdf...32
ipfw set 23 table IFACE add no-controls-here
ipfw set 23 table IFACE add fifteencharsmax
ipfw set 23 table IFACE add fifteencharsmaxasdf
ipfw set 23 table ADDR add whatever?works
ipfw set 23 table ADDR add whatever.works
ipfw set 23 table ADDR add whatever.resolves
ipfw set 23 table ADDR list
ipfw set 23 table ADDR add whatever
ipfw set 23 table ADDR add whatever?
ipfw set 23 table ADDR add what?ever
ipfw set 23 table ADDR add igb8 255.255.255.255
ipfw set 23 table ADDR add igb0 255.255.255.255
ipfw set 23 table ADDR add igb0 0
ipfw set 23 table all list
ipfw set 23 table all flush
ipfw set 23 table all list
ipfw set 23 table ADDR add igb0 255.255.255.255
ipfw set 23 table MAC add de:ad:be:ef:co:fe
ipfw set 23 table MAC add de:ad:be:ef:c0:fe
ipfw set 23 table MAC add de:ad:be:ef:c0:fe/12
ipfw set 23 table all list
ipfw set 23 table all flush
ipfw set 23 table MAC add de:ad:be:ef:c0:fe/12 de:ad:be:ef:c0:fe
ipfw set 23 table MAC add de:ad:be:ef:c0:fe/12 de:ad:be:ef:c0:fe/48
ipfw set 23 table MAC add de:ad:be:ef:c0:fe/12 0xffffffff de:ad:be:ef:c0:fe/48 0.0.0.0
ipfw set 23 table MAC list
ipfw set 23 table MAC add de:ad:be:ef:c0:fe
ipfw set 23 table MAC add de:ad:be
ipfw set 23 table NUMBER add asdf
ipfw set 23 table NUMBER add 42 0x0 23 255.255.255.0
ipfw set 23 table NUMBER add 63/2
ipfw set 23 table NUMBER add 63.1
ipfw set 23 table all list
ipfw set 23 table FLOW add asdf
ipfw set 23 table FLOW add 123
ipfw set 23 table FLOW add in
ipfw set 23 table FLOW add out
ipfw set 23 table FLOW add xmit
ipfw set 23 table all list
ipfw set 23 table FLOW detail
ipfw table TWOFLOW create type flow:src-ip,proto,dst-ip,dst-port
ipfw set 23 table TWOFLOW detail
ipfw set 0 table TWOFLOW detail
ipfw table ThreeFLOW create type flow:src-ip,proto,dst-port
ipfw table ThreeFLOW create type flow:proto,dst-port
ipfw table FourFLOW create type flow:proto,dst-port
ipfw table FourFLOW create type flow:dst-port
ipfw table FiveFLOW create type flow:dst-port
ipfw set 0 table all detail
ipfw set 0 table all list
ipfw set 0 table all type flow list
ipfw set 0 table type flow list
ipfw set 0 table all info
ipfw set 0 table all detail
ipfw set 0 table all info
ipfw set0 table DOESNOTEXISTACTUALLY destroy
ipfw set 0 table DOESNOTEXISTACTUALLY destroy
ipfw set 0 table all info
ipfw table sixFLOW create type flow:dst-port,
ipfw table sixFLOW create type flow:dst-port,asdf
ipfw table sevenFLOW create type flow:dst-port,proto
ipfw table sixFLOW info
ipfw table eightFLOW create type flow:proto,src-ip
ipfw table eightFLOW info
ipfw table sevenFLOW info
ipfw table nineFLOW create type flow:proto,src-ip 0xffffffff
ipfw set 0 table all list
ipfw set 23 table all list
ipfw set 23 table IFACE list
ipfw set 23 table IFACE asdf? as?df em0
ipfw set 23 table IFACE list
ipfw set 23 table IFACE em0 re0
ipfw set 23 table IFACE add asdf? as?df em0
ipfw set 23 table IFACE list
ipfw set 23 table IFACE add asdf em0
ipfw set 23 table IFACE list
ipfw set 23 table IFACE atomic add WHAT_EVA 1
ipfw set 23 table IFACE list
ipfw set 23 table IFACE add em0 0xffffffff
ipfw set 23 table IFACE add fifteencharsmax 0xffffffff
ipfw set 23 table FLOW add 10.0.0.1,udp,10.0.0.2,53 12
ipfw set 23 table FLOW add 10.0.0.1
ipfw set 23 table all list
ipfw set 0 table all list
ipfw set 0 table all info
ipfw set 0 table sevenFLOW add tcp80 0xffffffff
ipfw set 0 table sevenFLOW add tcp,80 0xffffffff
ipfw set 0 table sevenFLOW add tcp,80
ipfw set 0 table all list
ipfw set 0 table sevenFLOW add flow:tcp,80
ipfw set 0 table sevenFLOW add tcp,80
ipfw set 0 table sevenFLOW add udp,80
ipfw set 0 table sevenFLOW add 17,80
ipfw set 0 table sevenFLOW add 192.0.2.0,17,80
ipfw set 0 table sevenFLOW add 17,80
ipfw set 0 table WORKS create type flow:src-ip,proto,dst-ip,dst-port
ipfw table fl add 2a02:6b8:77::88,tcp,2a02:6b8:77::99,80 11
ipfw set 0 table list
ipfw set 0 table all list
ipfw set 0 table fl list
ipfw set 0 table fl info
ipfw set 0 table fl detail
ipfw table fl add 10.0.0.1,udp,10.0.0.2,53 12
ipfw set 0 table fl detail
ipfw set 0 table fl info
ipfw set 0 table fl list
ipfw table fl lookup 2a02:6b8:77::99
ipfw table fl lookup 10.0.0.1,udp,10.0.0.2,53 12
ipfw table fl create type flow:src-ip,proto,dst-ip,dst-port
ipfw table fl add 2a02:6b8:77::88,tcp,2a02:6b8:77::99,80 11
ipfw table fl add 10.0.0.1,udp,10.0.0.2,53 12
ipfw table all list
ipfw table fl list

Executing these commands leads to an error in how the output of ipfw table fl list ( fl is a table of type flow) looks like. Each existing table-key part within the table fl is truncated after 15 characters where it normally outputs the full flow table entry (table-key, followed by table-value); only flow-type tables are affected it seems.
Assuming that a whitespace character is involved and that one character is 8 bit it appears my sequence of commands somehow manages to make ipfw table fl list process only the first 16 bytes of a table-key for the output (followed by the table-value. I don't know where the remaining part of the table-keys go.

This is how the output looks like with the bug (15 chars of table-key, followed by table-value):
Code:
# ipfw table fl list
10.0.0.1,udp,10 12
2a02:6b8:77::88 11

This is how the output looks like before the bug is triggered:
Code:
# ipfw table fl list
10.0.0.1,udp,10.0.0.2,53 12
2a02:6b8:77::88,tcp,2a02:6b8:77::99,80 11

The last few commands are taken from the EXAMPLE section (LOOKUP TABLES subsection) of ipfw(8). When run in isolation, these EXAMPLE commands do not result in an truncated/incomplete output of a following ipfw table fl list.

How would someone receiving a bug report approach this? Is there a structured one size fits all way to find the cause of things like this? I get that the answer is somewhere in /usr/src/sbin/ipfw/ and might be related to the size of an array. But I believe I'd never be able to determine which of the commands above in the spoiler or which combination thereof is relevant.

EDIT: perhaps related - while experimenting I wrote down in my notes that certain table types wouldn't accept a table-value when adding a table entry. I removed this from my notes later and thought I made a typo. My history has timestamps and is set up to save lots of entries and I take my notes using Git, so perhaps I could reproduce this as well. I think it was table type iface and I was about to add table type flow as "not accepting table values".
 
Try asking on the mailing list or on IRC's FreeBSD rooms, then consider going ahead to file a bug report, no matter if it's minor.
 
Back
Top