Blame view
net/netfilter/nft_fib_netdev.c
2.23 KB
d2912cb15 treewide: Replace... |
1 |
// SPDX-License-Identifier: GPL-2.0-only |
6392c2260 netfilter: nf_tab... |
2 3 4 |
/* * Copyright (c) 2017 Pablo M. Bermudo Garay <pablombg@gmail.com> * |
6392c2260 netfilter: nf_tab... |
5 6 7 8 9 10 11 12 13 14 15 16 |
* This code is based on net/netfilter/nft_fib_inet.c, written by * Florian Westphal <fw@strlen.de>. */ #include <linux/kernel.h> #include <linux/init.h> #include <linux/module.h> #include <linux/netlink.h> #include <linux/netfilter.h> #include <linux/netfilter/nf_tables.h> #include <net/netfilter/nf_tables_core.h> #include <net/netfilter/nf_tables.h> |
882091413 netfilter: nft_fi... |
17 |
#include <net/ipv6.h> |
6392c2260 netfilter: nf_tab... |
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
#include <net/netfilter/nft_fib.h> static void nft_fib_netdev_eval(const struct nft_expr *expr, struct nft_regs *regs, const struct nft_pktinfo *pkt) { const struct nft_fib *priv = nft_expr_priv(expr); switch (ntohs(pkt->skb->protocol)) { case ETH_P_IP: switch (priv->result) { case NFT_FIB_RESULT_OIF: case NFT_FIB_RESULT_OIFNAME: return nft_fib4_eval(expr, regs, pkt); case NFT_FIB_RESULT_ADDRTYPE: return nft_fib4_eval_type(expr, regs, pkt); } break; case ETH_P_IPV6: |
882091413 netfilter: nft_fi... |
38 39 |
if (!ipv6_mod_enabled()) break; |
6392c2260 netfilter: nf_tab... |
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
switch (priv->result) { case NFT_FIB_RESULT_OIF: case NFT_FIB_RESULT_OIFNAME: return nft_fib6_eval(expr, regs, pkt); case NFT_FIB_RESULT_ADDRTYPE: return nft_fib6_eval_type(expr, regs, pkt); } break; } regs->verdict.code = NFT_BREAK; } static struct nft_expr_type nft_fib_netdev_type; static const struct nft_expr_ops nft_fib_netdev_ops = { .type = &nft_fib_netdev_type, .size = NFT_EXPR_SIZE(sizeof(struct nft_fib)), .eval = nft_fib_netdev_eval, .init = nft_fib_init, .dump = nft_fib_dump, .validate = nft_fib_validate, }; static struct nft_expr_type nft_fib_netdev_type __read_mostly = { .family = NFPROTO_NETDEV, .name = "fib", .ops = &nft_fib_netdev_ops, .policy = nft_fib_policy, .maxattr = NFTA_FIB_MAX, .owner = THIS_MODULE, }; static int __init nft_fib_netdev_module_init(void) { return nft_register_expr(&nft_fib_netdev_type); } static void __exit nft_fib_netdev_module_exit(void) { nft_unregister_expr(&nft_fib_netdev_type); } module_init(nft_fib_netdev_module_init); module_exit(nft_fib_netdev_module_exit); MODULE_LICENSE("GPL"); MODULE_AUTHOR("Pablo M. Bermudo Garay <pablombg@gmail.com>"); MODULE_ALIAS_NFT_AF_EXPR(5, "fib"); |
4cacc3951 netfilter: Add MO... |
88 |
MODULE_DESCRIPTION("nftables netdev fib lookups support"); |