2 * Copyright (c) 2014 Pablo Neira Ayuso <pablo@netfilter.org>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
9 #include <linux/kernel.h>
10 #include <linux/init.h>
11 #include <linux/module.h>
12 #include <linux/netlink.h>
13 #include <linux/netfilter.h>
14 #include <linux/netfilter/nf_tables.h>
15 #include <net/netfilter/nf_tables.h>
16 #include <net/netfilter/nft_reject.h>
18 static void nft_reject_bridge_eval(const struct nft_expr
*expr
,
19 struct nft_data data
[NFT_REG_MAX
+ 1],
20 const struct nft_pktinfo
*pkt
)
22 switch (eth_hdr(pkt
->skb
)->h_proto
) {
24 return nft_reject_ipv4_eval(expr
, data
, pkt
);
25 case htons(ETH_P_IPV6
):
26 return nft_reject_ipv6_eval(expr
, data
, pkt
);
28 /* No explicit way to reject this protocol, drop it. */
29 data
[NFT_REG_VERDICT
].verdict
= NF_DROP
;
34 static struct nft_expr_type nft_reject_bridge_type
;
35 static const struct nft_expr_ops nft_reject_bridge_ops
= {
36 .type
= &nft_reject_bridge_type
,
37 .size
= NFT_EXPR_SIZE(sizeof(struct nft_reject
)),
38 .eval
= nft_reject_bridge_eval
,
39 .init
= nft_reject_init
,
40 .dump
= nft_reject_dump
,
43 static struct nft_expr_type nft_reject_bridge_type __read_mostly
= {
44 .family
= NFPROTO_BRIDGE
,
46 .ops
= &nft_reject_bridge_ops
,
47 .policy
= nft_reject_policy
,
48 .maxattr
= NFTA_REJECT_MAX
,
52 static int __init
nft_reject_bridge_module_init(void)
54 return nft_register_expr(&nft_reject_bridge_type
);
57 static void __exit
nft_reject_bridge_module_exit(void)
59 nft_unregister_expr(&nft_reject_bridge_type
);
62 module_init(nft_reject_bridge_module_init
);
63 module_exit(nft_reject_bridge_module_exit
);
65 MODULE_LICENSE("GPL");
66 MODULE_AUTHOR("Pablo Neira Ayuso <pablo@netfilter.org>");
67 MODULE_ALIAS_NFT_AF_EXPR(AF_BRIDGE
, "reject");