1 // SPDX-License-Identifier: GPL-2.0-only
6 * Chris Vitale csv@bluetail.com
11 #include <linux/module.h>
12 #include <linux/netfilter/x_tables.h>
13 #include <linux/netfilter_bridge/ebtables.h>
14 #include <linux/netfilter_bridge/ebt_802_3.h>
17 ebt_802_3_mt(const struct sk_buff *skb, struct xt_action_param *par)
19 const struct ebt_802_3_info *info = par->matchinfo;
20 const struct ebt_802_3_hdr *hdr = ebt_802_3_hdr(skb);
21 __be16 type = hdr->llc.ui.ctrl & IS_UI ? hdr->llc.ui.type : hdr->llc.ni.type;
23 if (info->bitmask & EBT_802_3_SAP) {
24 if (NF_INVF(info, EBT_802_3_SAP, info->sap != hdr->llc.ui.ssap))
26 if (NF_INVF(info, EBT_802_3_SAP, info->sap != hdr->llc.ui.dsap))
30 if (info->bitmask & EBT_802_3_TYPE) {
31 if (!(hdr->llc.ui.dsap == CHECK_TYPE && hdr->llc.ui.ssap == CHECK_TYPE))
33 if (NF_INVF(info, EBT_802_3_TYPE, info->type != type))
40 static int ebt_802_3_mt_check(const struct xt_mtchk_param *par)
42 const struct ebt_802_3_info *info = par->matchinfo;
44 if (info->bitmask & ~EBT_802_3_MASK || info->invflags & ~EBT_802_3_MASK)
50 static struct xt_match ebt_802_3_mt_reg __read_mostly = {
53 .family = NFPROTO_BRIDGE,
54 .match = ebt_802_3_mt,
55 .checkentry = ebt_802_3_mt_check,
56 .matchsize = sizeof(struct ebt_802_3_info),
60 static int __init ebt_802_3_init(void)
62 return xt_register_match(&ebt_802_3_mt_reg);
65 static void __exit ebt_802_3_fini(void)
67 xt_unregister_match(&ebt_802_3_mt_reg);
70 module_init(ebt_802_3_init);
71 module_exit(ebt_802_3_fini);
72 MODULE_DESCRIPTION("Ebtables: DSAP/SSAP field and SNAP type matching");
73 MODULE_LICENSE("GPL");