cregit-Linux how code gets into the kernel

Release 4.11 net/bridge/netfilter/ebtable_nat.c

/*
 *  ebtable_nat
 *
 *      Authors:
 *      Bart De Schuymer <bdschuym@pandora.be>
 *
 *  April, 2002
 *
 */

#include <linux/netfilter_bridge/ebtables.h>
#include <linux/module.h>


#define NAT_VALID_HOOKS ((1 << NF_BR_PRE_ROUTING) | (1 << NF_BR_LOCAL_OUT) | \
                         (1 << NF_BR_POST_ROUTING))


static struct ebt_entries initial_chains[] = {
	{
		.name	= "PREROUTING",
		.policy	= EBT_ACCEPT,
        },
	{
		.name	= "OUTPUT",
		.policy	= EBT_ACCEPT,
        },
	{
		.name	= "POSTROUTING",
		.policy	= EBT_ACCEPT,
        }
};


static struct ebt_replace_kernel initial_table = {
	.name		= "nat",
	.valid_hooks	= NAT_VALID_HOOKS,
	.entries_size	= 3 * sizeof(struct ebt_entries),
	.hook_entry	= {
		[NF_BR_PRE_ROUTING]	= &initial_chains[0],
		[NF_BR_LOCAL_OUT]	= &initial_chains[1],
		[NF_BR_POST_ROUTING]	= &initial_chains[2],
        },
	.entries	= (char *)initial_chains,
};


static int check(const struct ebt_table_info *info, unsigned int valid_hooks) { if (valid_hooks & ~NAT_VALID_HOOKS) return -EINVAL; return 0; }

Contributors

PersonTokensPropCommitsCommitProp
Bart De Schuymer30100.00%1100.00%
Total30100.00%1100.00%

static struct ebt_table frame_nat = { .name = "nat", .table = &initial_table, .valid_hooks = NAT_VALID_HOOKS, .check = check, .me = THIS_MODULE, };
static unsigned int ebt_nat_in(void *priv, struct sk_buff *skb, const struct nf_hook_state *state) { return ebt_do_table(skb, state, state->net->xt.frame_nat); }

Contributors

PersonTokensPropCommitsCommitProp
Bart De Schuymer2360.53%114.29%
David S. Miller513.16%114.29%
Alexey Dobriyan410.53%114.29%
Eric W. Biedermann37.89%228.57%
Herbert Xu25.26%114.29%
Patrick McHardy12.63%114.29%
Total38100.00%7100.00%


static unsigned int ebt_nat_out(void *priv, struct sk_buff *skb, const struct nf_hook_state *state) { return ebt_do_table(skb, state, state->net->xt.frame_nat); }

Contributors

PersonTokensPropCommitsCommitProp
Bart De Schuymer2360.53%114.29%
David S. Miller513.16%114.29%
Alexey Dobriyan410.53%114.29%
Eric W. Biedermann37.89%228.57%
Herbert Xu25.26%114.29%
Patrick McHardy12.63%114.29%
Total38100.00%7100.00%

static struct nf_hook_ops ebt_ops_nat[] __read_mostly = { { .hook = ebt_nat_out, .pf = NFPROTO_BRIDGE, .hooknum = NF_BR_LOCAL_OUT, .priority = NF_BR_PRI_NAT_DST_OTHER, }, { .hook = ebt_nat_out, .pf = NFPROTO_BRIDGE, .hooknum = NF_BR_POST_ROUTING, .priority = NF_BR_PRI_NAT_SRC, }, { .hook = ebt_nat_in, .pf = NFPROTO_BRIDGE, .hooknum = NF_BR_PRE_ROUTING, .priority = NF_BR_PRI_NAT_DST_BRIDGED, }, };
static int __net_init frame_nat_net_init(struct net *net) { net->xt.frame_nat = ebt_register_table(net, &frame_nat); return PTR_ERR_OR_ZERO(net->xt.frame_nat); }

Contributors

PersonTokensPropCommitsCommitProp
Alexey Dobriyan2466.67%360.00%
Bart De Schuymer1130.56%120.00%
Rusty Russell12.78%120.00%
Total36100.00%5100.00%


static void __net_exit frame_nat_net_exit(struct net *net) { ebt_unregister_table(net, net->xt.frame_nat); }

Contributors

PersonTokensPropCommitsCommitProp
Alexey Dobriyan23100.00%3100.00%
Total23100.00%3100.00%

static struct pernet_operations frame_nat_net_ops = { .init = frame_nat_net_init, .exit = frame_nat_net_exit, };
static int __init ebtable_nat_init(void) { int ret; ret = register_pernet_subsys(&frame_nat_net_ops); if (ret < 0) return ret; ret = nf_register_hooks(ebt_ops_nat, ARRAY_SIZE(ebt_ops_nat)); if (ret < 0) unregister_pernet_subsys(&frame_nat_net_ops); return ret; }

Contributors

PersonTokensPropCommitsCommitProp
Alexey Dobriyan3766.07%250.00%
Bart De Schuymer1832.14%125.00%
Andries E. Brouwer11.79%125.00%
Total56100.00%4100.00%


static void __exit ebtable_nat_fini(void) { nf_unregister_hooks(ebt_ops_nat, ARRAY_SIZE(ebt_ops_nat)); unregister_pernet_subsys(&frame_nat_net_ops); }

Contributors

PersonTokensPropCommitsCommitProp
Bart De Schuymer1768.00%125.00%
Alexey Dobriyan728.00%250.00%
Andrew Morton14.00%125.00%
Total25100.00%4100.00%

module_init(ebtable_nat_init); module_exit(ebtable_nat_fini); MODULE_LICENSE("GPL");

Overall Contributors

PersonTokensPropCommitsCommitProp
Bart De Schuymer27152.83%314.29%
Alexey Dobriyan12023.39%523.81%
Art Haas8917.35%14.76%
David S. Miller101.95%14.76%
Eric W. Biedermann61.17%29.52%
Herbert Xu40.78%14.76%
Jan Engelhardt30.58%14.76%
Patrick McHardy30.58%29.52%
Andrew Morton30.58%14.76%
Andries E. Brouwer10.19%14.76%
Rusty Russell10.19%14.76%
Ian Morris10.19%14.76%
Al Viro10.19%14.76%
Total513100.00%21100.00%
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.
Created with cregit.