~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/net/netfilter/nft_dup_netdev.c

Version: ~ [ linux-5.4-rc7 ] ~ [ linux-5.3.11 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.84 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.154 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.201 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.201 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.140 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.77 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-3.9.11 ] ~ [ linux-3.8.13 ] ~ [ linux-3.7.10 ] ~ [ linux-3.6.11 ] ~ [ linux-3.5.7 ] ~ [ linux-3.4.113 ] ~ [ linux-3.3.8 ] ~ [ linux-3.2.102 ] ~ [ linux-3.1.10 ] ~ [ linux-3.0.101 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /*
  2  * Copyright (c) 2015 Pablo Neira Ayuso <pablo@netfilter.org>
  3  *
  4  * This program is free software; you can redistribute it and/or modify it
  5  * under the terms of the GNU General Public License version 2 as published by
  6  * the Free Software Foundation.
  7  */
  8 
  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/nf_dup_netdev.h>
 17 
 18 struct nft_dup_netdev {
 19         enum nft_registers      sreg_dev:8;
 20 };
 21 
 22 static void nft_dup_netdev_eval(const struct nft_expr *expr,
 23                                 struct nft_regs *regs,
 24                                 const struct nft_pktinfo *pkt)
 25 {
 26         struct nft_dup_netdev *priv = nft_expr_priv(expr);
 27         int oif = regs->data[priv->sreg_dev];
 28 
 29         nf_dup_netdev_egress(pkt, oif);
 30 }
 31 
 32 static const struct nla_policy nft_dup_netdev_policy[NFTA_DUP_MAX + 1] = {
 33         [NFTA_DUP_SREG_DEV]     = { .type = NLA_U32 },
 34 };
 35 
 36 static int nft_dup_netdev_init(const struct nft_ctx *ctx,
 37                                const struct nft_expr *expr,
 38                                const struct nlattr * const tb[])
 39 {
 40         struct nft_dup_netdev *priv = nft_expr_priv(expr);
 41 
 42         if (tb[NFTA_DUP_SREG_DEV] == NULL)
 43                 return -EINVAL;
 44 
 45         priv->sreg_dev = nft_parse_register(tb[NFTA_DUP_SREG_DEV]);
 46         return nft_validate_register_load(priv->sreg_dev, sizeof(int));
 47 }
 48 
 49 static const struct nft_expr_ops nft_dup_netdev_ingress_ops;
 50 
 51 static int nft_dup_netdev_dump(struct sk_buff *skb, const struct nft_expr *expr)
 52 {
 53         struct nft_dup_netdev *priv = nft_expr_priv(expr);
 54 
 55         if (nft_dump_register(skb, NFTA_DUP_SREG_DEV, priv->sreg_dev))
 56                 goto nla_put_failure;
 57 
 58         return 0;
 59 
 60 nla_put_failure:
 61         return -1;
 62 }
 63 
 64 static struct nft_expr_type nft_dup_netdev_type;
 65 static const struct nft_expr_ops nft_dup_netdev_ops = {
 66         .type           = &nft_dup_netdev_type,
 67         .size           = NFT_EXPR_SIZE(sizeof(struct nft_dup_netdev)),
 68         .eval           = nft_dup_netdev_eval,
 69         .init           = nft_dup_netdev_init,
 70         .dump           = nft_dup_netdev_dump,
 71 };
 72 
 73 static struct nft_expr_type nft_dup_netdev_type __read_mostly = {
 74         .family         = NFPROTO_NETDEV,
 75         .name           = "dup",
 76         .ops            = &nft_dup_netdev_ops,
 77         .policy         = nft_dup_netdev_policy,
 78         .maxattr        = NFTA_DUP_MAX,
 79         .owner          = THIS_MODULE,
 80 };
 81 
 82 static int __init nft_dup_netdev_module_init(void)
 83 {
 84         return nft_register_expr(&nft_dup_netdev_type);
 85 }
 86 
 87 static void __exit nft_dup_netdev_module_exit(void)
 88 {
 89         nft_unregister_expr(&nft_dup_netdev_type);
 90 }
 91 
 92 module_init(nft_dup_netdev_module_init);
 93 module_exit(nft_dup_netdev_module_exit);
 94 
 95 MODULE_LICENSE("GPL");
 96 MODULE_AUTHOR("Pablo Neira Ayuso <pablo@netfilter.org>");
 97 MODULE_ALIAS_NFT_AF_EXPR(5, "dup");
 98 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp