git: 84b41342da1f - main - ipfw: add eaction tests
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 15 Jun 2023 06:36:43 UTC
The branch main has been updated by melifaro: URL: https://cgit.FreeBSD.org/src/commit/?id=84b41342da1ff3b9cf4eb785752201575c5e4391 commit 84b41342da1ff3b9cf4eb785752201575c5e4391 Author: Alexander V. Chernikov <melifaro@FreeBSD.org> AuthorDate: 2023-06-15 06:36:16 +0000 Commit: Alexander V. Chernikov <melifaro@FreeBSD.org> CommitDate: 2023-06-15 06:36:16 +0000 ipfw: add eaction tests MFC after: 2 weeks --- sbin/ipfw/tests/test_add_rule.py | 33 ++++++++++++++++++++++++++++++ tests/atf_python/sys/netpfil/ipfw/ioctl.py | 6 ++++++ 2 files changed, 39 insertions(+) diff --git a/sbin/ipfw/tests/test_add_rule.py b/sbin/ipfw/tests/test_add_rule.py index 65b4e7d33646..42c594a83bcf 100755 --- a/sbin/ipfw/tests/test_add_rule.py +++ b/sbin/ipfw/tests/test_add_rule.py @@ -173,6 +173,39 @@ class TestAddRule(BaseTest): }, id="test_comment", ), + pytest.param( + { + "in": "add tcp-setmss 123 ip from any to 1.2.3.4", + "out": { + "objs": [ + NTlv(IpFwTlvType.IPFW_TLV_EACTION, idx=1, name="tcp-setmss"), + ], + "insns": [ + InsnIp(IpFwOpcode.O_IP_DST, ip="1.2.3.4"), + Insn(IpFwOpcode.O_EXTERNAL_ACTION, arg1=1), + Insn(IpFwOpcode.O_EXTERNAL_DATA, arg1=123), + ], + }, + }, + id="test_eaction_tcp-setmss", + ), + pytest.param( + { + "in": "add eaction ntpv6 AAA ip from any to 1.2.3.4", + "out": { + "objs": [ + NTlv(IpFwTlvType.IPFW_TLV_EACTION, idx=1, name="ntpv6"), + NTlv(0, idx=2, name="AAA"), + ], + "insns": [ + InsnIp(IpFwOpcode.O_IP_DST, ip="1.2.3.4"), + Insn(IpFwOpcode.O_EXTERNAL_ACTION, arg1=1), + Insn(IpFwOpcode.O_EXTERNAL_INSTANCE, arg1=2), + ], + }, + }, + id="test_eaction_ntp", + ), ], ) def test_add_rule(self, rule): diff --git a/tests/atf_python/sys/netpfil/ipfw/ioctl.py b/tests/atf_python/sys/netpfil/ipfw/ioctl.py index 45ba96a7fb70..4c6d3f234c6c 100644 --- a/tests/atf_python/sys/netpfil/ipfw/ioctl.py +++ b/tests/atf_python/sys/netpfil/ipfw/ioctl.py @@ -90,6 +90,11 @@ class BaseTlv(object): for obj in self.obj_list: obj.print_obj(prepend) + def print_obj_hex(self, prepend=""): + print(prepend) + print() + print(" ".join(["x{:02X}".format(b) for b in bytes(self)])) + @classmethod def _validate(cls, data): if len(data) < sizeof(IpFwObjTlv): @@ -487,6 +492,7 @@ rule_attrs = prepare_attrs_map( [ AttrDescr(IpFwTlvType.IPFW_TLV_TBL_NAME, NTlv), AttrDescr(IpFwTlvType.IPFW_TLV_STATE_NAME, NTlv), + AttrDescr(IpFwTlvType.IPFW_TLV_EACTION, NTlv), ], True, ),