]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blob - net/netfilter/nft_fib_inet.c
Merge tag 'nfs-for-4.13-5' of git://git.linux-nfs.org/projects/anna/linux-nfs
[mirror_ubuntu-artful-kernel.git] / net / netfilter / nft_fib_inet.c
1 /*
2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License version 2 as
4 * published by the Free Software Foundation.
5 */
6
7 #include <linux/kernel.h>
8 #include <linux/init.h>
9 #include <linux/module.h>
10 #include <linux/netlink.h>
11 #include <linux/netfilter.h>
12 #include <linux/netfilter/nf_tables.h>
13 #include <net/netfilter/nf_tables_core.h>
14 #include <net/netfilter/nf_tables.h>
15
16 #include <net/netfilter/nft_fib.h>
17
18 static void nft_fib_inet_eval(const struct nft_expr *expr,
19 struct nft_regs *regs,
20 const struct nft_pktinfo *pkt)
21 {
22 const struct nft_fib *priv = nft_expr_priv(expr);
23
24 switch (nft_pf(pkt)) {
25 case NFPROTO_IPV4:
26 switch (priv->result) {
27 case NFT_FIB_RESULT_OIF:
28 case NFT_FIB_RESULT_OIFNAME:
29 return nft_fib4_eval(expr, regs, pkt);
30 case NFT_FIB_RESULT_ADDRTYPE:
31 return nft_fib4_eval_type(expr, regs, pkt);
32 }
33 break;
34 case NFPROTO_IPV6:
35 switch (priv->result) {
36 case NFT_FIB_RESULT_OIF:
37 case NFT_FIB_RESULT_OIFNAME:
38 return nft_fib6_eval(expr, regs, pkt);
39 case NFT_FIB_RESULT_ADDRTYPE:
40 return nft_fib6_eval_type(expr, regs, pkt);
41 }
42 break;
43 }
44
45 regs->verdict.code = NF_DROP;
46 }
47
48 static struct nft_expr_type nft_fib_inet_type;
49 static const struct nft_expr_ops nft_fib_inet_ops = {
50 .type = &nft_fib_inet_type,
51 .size = NFT_EXPR_SIZE(sizeof(struct nft_fib)),
52 .eval = nft_fib_inet_eval,
53 .init = nft_fib_init,
54 .dump = nft_fib_dump,
55 .validate = nft_fib_validate,
56 };
57
58 static struct nft_expr_type nft_fib_inet_type __read_mostly = {
59 .family = NFPROTO_INET,
60 .name = "fib",
61 .ops = &nft_fib_inet_ops,
62 .policy = nft_fib_policy,
63 .maxattr = NFTA_FIB_MAX,
64 .owner = THIS_MODULE,
65 };
66
67 static int __init nft_fib_inet_module_init(void)
68 {
69 return nft_register_expr(&nft_fib_inet_type);
70 }
71
72 static void __exit nft_fib_inet_module_exit(void)
73 {
74 nft_unregister_expr(&nft_fib_inet_type);
75 }
76
77 module_init(nft_fib_inet_module_init);
78 module_exit(nft_fib_inet_module_exit);
79
80 MODULE_LICENSE("GPL");
81 MODULE_AUTHOR("Florian Westphal <fw@strlen.de>");
82 MODULE_ALIAS_NFT_AF_EXPR(1, "fib");