Release 4.11 net/netfilter/nf_tables_api.c
/*
* Copyright (c) 2007-2009 Patrick McHardy <kaber@trash.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* Development of this code funded by Astaro AG (http://www.astaro.com/)
*/
#include <linux/module.h>
#include <linux/init.h>
#include <linux/list.h>
#include <linux/skbuff.h>
#include <linux/netlink.h>
#include <linux/netfilter.h>
#include <linux/netfilter/nfnetlink.h>
#include <linux/netfilter/nf_tables.h>
#include <net/netfilter/nf_tables_core.h>
#include <net/netfilter/nf_tables.h>
#include <net/net_namespace.h>
#include <net/sock.h>
static LIST_HEAD(nf_tables_expressions);
static LIST_HEAD(nf_tables_objects);
/**
* nft_register_afinfo - register nf_tables address family info
*
* @afi: address family info to register
*
* Register the address family for use with nf_tables. Returns zero on
* success or a negative errno code otherwise.
*/
int nft_register_afinfo(struct net *net, struct nft_af_info *afi)
{
INIT_LIST_HEAD(&afi->tables);
nfnl_lock(NFNL_SUBSYS_NFTABLES);
list_add_tail_rcu(&afi->list, &net->nft.af_info);
nfnl_unlock(NFNL_SUBSYS_NFTABLES);
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Patrick McHardy | 40 | 78.43% | 1 | 33.33% |
Pablo Neira Ayuso | 11 | 21.57% | 2 | 66.67% |
Total | 51 | 100.00% | 3 | 100.00% |
EXPORT_SYMBOL_GPL(nft_register_afinfo);
static void __nft_release_afinfo(struct net *net, struct nft_af_info *afi);
/**
* nft_unregister_afinfo - unregister nf_tables address family info
*
* @afi: address family info to unregister
*
* Unregister the address family for use with nf_tables.
*/
void nft_unregister_afinfo(struct net *net, struct nft_af_info *afi)
{
nfnl_lock(NFNL_SUBSYS_NFTABLES);
__nft_release_afinfo(net, afi);
list_del_rcu(&afi->list);
nfnl_unlock(NFNL_SUBSYS_NFTABLES);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Patrick McHardy | 27 | 67.50% | 1 | 33.33% |
Pablo Neira Ayuso | 13 | 32.50% | 2 | 66.67% |
Total | 40 | 100.00% | 3 | 100.00% |
EXPORT_SYMBOL_GPL(nft_unregister_afinfo);
static struct nft_af_info *nft_afinfo_lookup(struct net *net, int family)
{
struct nft_af_info *afi;
list_for_each_entry(afi, &net->nft.af_info, list) {
if (afi->family == family)
return afi;
}
return NULL;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Patrick McHardy | 39 | 86.67% | 1 | 50.00% |
Pablo Neira Ayuso | 6 | 13.33% | 1 | 50.00% |
Total | 45 | 100.00% | 2 | 100.00% |
static struct nft_af_info *
nf_tables_afinfo_lookup(struct net *net, int family, bool autoload)
{
struct nft_af_info *afi;
afi = nft_afinfo_lookup(net, family);
if (afi != NULL)
return afi;
#ifdef CONFIG_MODULES
if (autoload) {
nfnl_unlock(NFNL_SUBSYS_NFTABLES);
request_module("nft-afinfo-%u", family);
nfnl_lock(NFNL_SUBSYS_NFTABLES);
afi = nft_afinfo_lookup(net, family);
if (afi != NULL)
return ERR_PTR(-EAGAIN);
}
#endif
return ERR_PTR(-EAFNOSUPPORT);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Patrick McHardy | 90 | 90.91% | 1 | 50.00% |
Pablo Neira Ayuso | 9 | 9.09% | 1 | 50.00% |
Total | 99 | 100.00% | 2 | 100.00% |
static void nft_ctx_init(struct nft_ctx *ctx,
struct net *net,
const struct sk_buff *skb,
const struct nlmsghdr *nlh,
struct nft_af_info *afi,
struct nft_table *table,
struct nft_chain *chain,
const struct nlattr * const *nla)
{
ctx->net = net;
ctx->afi = afi;
ctx->table = table;
ctx->chain = chain;
ctx->nla = nla;
ctx->portid = NETLINK_CB(skb).portid;
ctx->report = nlmsg_report(nlh);
ctx->seq = nlh->nlmsg_seq;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Pablo Neira Ayuso | 109 | 100.00% | 3 | 100.00% |
Total | 109 | 100.00% | 3 | 100.00% |
static struct nft_trans *nft_trans_alloc_gfp(const struct nft_ctx *ctx,
int msg_type, u32 size, gfp_t gfp)
{
struct nft_trans *trans;
trans = kzalloc(sizeof(struct nft_trans) + size, gfp);
if (trans == NULL)
return NULL;
trans->msg_type = msg_type;
trans->ctx = *ctx;
return trans;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Pablo Neira Ayuso | 68 | 100.00% | 4 | 100.00% |
Total | 68 | 100.00% | 4 | 100.00% |
static struct nft_trans *nft_trans_alloc(const struct nft_ctx *ctx,
int msg_type, u32 size)
{
return nft_trans_alloc_gfp(ctx, msg_type, size, GFP_KERNEL);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Pablo Neira Ayuso | 32 | 100.00% | 1 | 100.00% |
Total | 32 | 100.00% | 1 | 100.00% |
static void nft_trans_destroy(struct nft_trans *trans)
{
list_del(&trans->list);
kfree(trans);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Pablo Neira Ayuso | 24 | 100.00% | 1 | 100.00% |
Total | 24 | 100.00% | 1 | 100.00% |
static int nf_tables_register_hooks(struct net *net,
const struct nft_table *table,
struct nft_chain *chain,
unsigned int hook_nops)
{
if (table->flags & NFT_TABLE_F_DORMANT ||
!(chain->flags & NFT_BASE_CHAIN))
return 0;
return nf_register_net_hooks(net, nft_base_chain(chain)->ops,
hook_nops);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Pablo Neira Ayuso | 38 | 62.30% | 3 | 60.00% |
Arturo Borrero Gonzalez | 20 | 32.79% | 1 | 20.00% |
Eric W. Biedermann | 3 | 4.92% | 1 | 20.00% |
Total | 61 | 100.00% | 5 | 100.00% |
static void nf_tables_unregister_hooks(struct net *net,
const struct nft_table *table,
struct nft_chain *chain,
unsigned int hook_nops)
{
if (table->flags & NFT_TABLE_F_DORMANT ||
!(chain->flags & NFT_BASE_CHAIN))
return;
nf_unregister_net_hooks(net, nft_base_chain(chain)->ops, hook_nops);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Pablo Neira Ayuso | 37 | 63.79% | 2 | 66.67% |
Arturo Borrero Gonzalez | 21 | 36.21% | 1 | 33.33% |
Total | 58 | 100.00% | 3 | 100.00% |
static int nft_trans_table_add(struct nft_ctx *ctx, int msg_type)
{
struct nft_trans *trans;
trans = nft_trans_alloc(ctx, msg_type, sizeof(struct nft_trans_table));
if (trans == NULL)
return -ENOMEM;
if (msg_type == NFT_MSG_NEWTABLE)
nft_activate_next(ctx->net, ctx->table);
list_add_tail(&trans->list, &ctx->net->nft.commit_list);
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Arturo Borrero Gonzalez | 51 | 62.96% | 1 | 33.33% |
Patrick McHardy | 23 | 28.40% | 1 | 33.33% |
Pablo Neira Ayuso | 7 | 8.64% | 1 | 33.33% |
Total | 81 | 100.00% | 3 | 100.00% |
static int nft_deltable(struct nft_ctx *ctx)
{
int err;
err = nft_trans_table_add(ctx, NFT_MSG_DELTABLE);
if (err < 0)
return err;
nft_deactivate_next(ctx->net, ctx->table);
return err;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Arturo Borrero Gonzalez | 27 | 58.70% | 1 | 33.33% |
Patrick McHardy | 14 | 30.43% | 1 | 33.33% |
Pablo Neira Ayuso | 5 | 10.87% | 1 | 33.33% |
Total | 46 | 100.00% | 3 | 100.00% |
static int nft_trans_chain_add(struct nft_ctx *ctx, int msg_type)
{
struct nft_trans *trans;
trans = nft_trans_alloc(ctx, msg_type, sizeof(struct nft_trans_chain));
if (trans == NULL)
return -ENOMEM;
if (msg_type == NFT_MSG_NEWCHAIN)
nft_activate_next(ctx->net, ctx->chain);
list_add_tail(&trans->list, &ctx->net->nft.commit_list);
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Arturo Borrero Gonzalez | 59 | 72.84% | 1 | 25.00% |
Pablo Neira Ayuso | 11 | 13.58% | 2 | 50.00% |
Patrick McHardy | 11 | 13.58% | 1 | 25.00% |
Total | 81 | 100.00% | 4 | 100.00% |
static int nft_delchain(struct nft_ctx *ctx)
{
int err;
err = nft_trans_chain_add(ctx, NFT_MSG_DELCHAIN);
if (err < 0)
return err;
ctx->table->use--;
nft_deactivate_next(ctx->net, ctx->chain);
return err;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Arturo Borrero Gonzalez | 38 | 71.70% | 1 | 33.33% |
Pablo Neira Ayuso | 15 | 28.30% | 2 | 66.67% |
Total | 53 | 100.00% | 3 | 100.00% |
static int
nf_tables_delrule_deactivate(struct nft_ctx *ctx, struct nft_rule *rule)
{
/* You cannot delete the same rule twice */
if (nft_is_active_next(ctx->net, rule)) {
nft_deactivate_next(ctx->net, rule);
ctx->chain->use--;
return 0;
}
return -ENOENT;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Arturo Borrero Gonzalez | 33 | 62.26% | 1 | 20.00% |
Patrick McHardy | 15 | 28.30% | 2 | 40.00% |
Pablo Neira Ayuso | 5 | 9.43% | 2 | 40.00% |
Total | 53 | 100.00% | 5 | 100.00% |
static struct nft_trans *nft_trans_rule_add(struct nft_ctx *ctx, int msg_type,
struct nft_rule *rule)
{
struct nft_trans *trans;
trans = nft_trans_alloc(ctx, msg_type, sizeof(struct nft_trans_rule));
if (trans == NULL)
return NULL;
if (msg_type == NFT_MSG_NEWRULE && ctx->nla[NFTA_RULE_ID] != NULL) {
nft_trans_rule_id(trans) =
ntohl(nla_get_be32(ctx->nla[NFTA_RULE_ID]));
}
nft_trans_rule(trans) = rule;
list_add_tail(&trans->list, &ctx->net->nft.commit_list);
return trans;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Patrick McHardy | 40 | 35.71% | 1 | 20.00% |
Pablo Neira Ayuso | 37 | 33.04% | 2 | 40.00% |
Arturo Borrero Gonzalez | 34 | 30.36% | 1 | 20.00% |
Tomasz Bursztyka | 1 | 0.89% | 1 | 20.00% |
Total | 112 | 100.00% | 5 | 100.00% |
static int nft_delrule(struct nft_ctx *ctx, struct nft_rule *rule)
{
struct nft_trans *trans;
int err;
trans = nft_trans_rule_add(ctx, NFT_MSG_DELRULE, rule);
if (trans == NULL)
return -ENOMEM;
err = nf_tables_delrule_deactivate(ctx, rule);
if (err < 0) {
nft_trans_destroy(trans);
return err;
}
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Patrick McHardy | 42 | 57.53% | 1 | 25.00% |
Arturo Borrero Gonzalez | 27 | 36.99% | 1 | 25.00% |
Pablo Neira Ayuso | 4 | 5.48% | 2 | 50.00% |
Total | 73 | 100.00% | 4 | 100.00% |
static int nft_delrule_by_chain(struct nft_ctx *ctx)
{
struct nft_rule *rule;
int err;
list_for_each_entry(rule, &ctx->chain->rules, list) {
err = nft_delrule(ctx, rule);
if (err < 0)
return err;
}
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Arturo Borrero Gonzalez | 31 | 62.00% | 1 | 33.33% |
Patrick McHardy | 17 | 34.00% | 1 | 33.33% |
Pablo Neira Ayuso | 2 | 4.00% | 1 | 33.33% |
Total | 50 | 100.00% | 3 | 100.00% |
static int nft_trans_set_add(struct nft_ctx *ctx, int msg_type,
struct nft_set *set)
{
struct nft_trans *trans;
trans = nft_trans_alloc(ctx, msg_type, sizeof(struct nft_trans_set));
if (trans == NULL)
return -ENOMEM;
if (msg_type == NFT_MSG_NEWSET && ctx->nla[NFTA_SET_ID] != NULL) {
nft_trans_set_id(trans) =
ntohl(nla_get_be32(ctx->nla[NFTA_SET_ID]));
nft_activate_next(ctx->net, set);
}
nft_trans_set(trans) = set;
list_add_tail(&trans->list, &ctx->net->nft.commit_list);
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Arturo Borrero Gonzalez | 72 | 60.00% | 1 | 20.00% |
Patrick McHardy | 38 | 31.67% | 1 | 20.00% |
Pablo Neira Ayuso | 10 | 8.33% | 3 | 60.00% |
Total | 120 | 100.00% | 5 | 100.00% |
static int nft_delset(struct nft_ctx *ctx, struct nft_set *set)
{
int err;
err = nft_trans_set_add(ctx, NFT_MSG_DELSET, set);
if (err < 0)
return err;
nft_deactivate_next(ctx->net, set);
ctx->table->use--;
return err;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Arturo Borrero Gonzalez | 39 | 67.24% | 1 | 25.00% |
Patrick McHardy | 11 | 18.97% | 1 | 25.00% |
Pablo Neira Ayuso | 8 | 13.79% | 2 | 50.00% |
Total | 58 | 100.00% | 4 | 100.00% |
static int nft_trans_obj_add(struct nft_ctx *ctx, int msg_type,
struct nft_object *obj)
{
struct nft_trans *trans;
trans = nft_trans_alloc(ctx, msg_type, sizeof(struct nft_trans_obj));
if (trans == NULL)
return -ENOMEM;
if (msg_type == NFT_MSG_NEWOBJ)
nft_activate_next(ctx->net, obj);
nft_trans_obj(trans) = obj;
list_add_tail(&trans->list, &ctx->net->nft.commit_list);
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Pablo Neira Ayuso | 91 | 100.00% | 1 | 100.00% |
Total | 91 | 100.00% | 1 | 100.00% |
static int nft_delobj(struct nft_ctx *ctx, struct nft_object *obj)
{
int err;
err = nft_trans_obj_add(ctx, NFT_MSG_DELOBJ, obj);
if (err < 0)
return err;
nft_deactivate_next(ctx->net, obj);
ctx->table->use--;
return err;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Pablo Neira Ayuso | 58 | 100.00% | 1 | 100.00% |
Total | 58 | 100.00% | 1 | 100.00% |
/*
* Tables
*/
static struct nft_table *nft_table_lookup(const struct nft_af_info *afi,
const struct nlattr *nla,
u8 genmask)
{
struct nft_table *table;
list_for_each_entry(table, &afi->tables, list) {
if (!nla_strcmp(nla, table->name) &&
nft_active_genmask(table, genmask))
return table;
}
return NULL;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Patrick McHardy | 26 | 41.27% | 1 | 25.00% |
Arturo Borrero Gonzalez | 25 | 39.68% | 1 | 25.00% |
Pablo Neira Ayuso | 12 | 19.05% | 2 | 50.00% |
Total | 63 | 100.00% | 4 | 100.00% |
static struct nft_table *nf_tables_table_lookup(const struct nft_af_info *afi,
const struct nlattr *nla,
u8 genmask)
{
struct nft_table *table;
if (nla == NULL)
return ERR_PTR(-EINVAL);
table = nft_table_lookup(afi, nla, genmask);
if (table != NULL)
return table;
return ERR_PTR(-ENOENT);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Arturo Borrero Gonzalez | 35 | 51.47% | 1 | 25.00% |
Patrick McHardy | 25 | 36.76% | 1 | 25.00% |
Pablo Neira Ayuso | 8 | 11.76% | 2 | 50.00% |
Total | 68 | 100.00% | 4 | 100.00% |
static inline u64 nf_tables_alloc_handle(struct nft_table *table)
{
return ++table->hgenerator;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Arturo Borrero Gonzalez | 14 | 77.78% | 1 | 50.00% |
Patrick McHardy | 4 | 22.22% | 1 | 50.00% |
Total | 18 | 100.00% | 2 | 100.00% |
static const struct nf_chain_type *chain_type[AF_MAX][NFT_CHAIN_T_MAX];
static const struct nf_chain_type *
__nf_tables_chain_type_lookup(int family, const struct nlattr *nla)
{
int i;
for (i = 0; i < NFT_CHAIN_T_MAX; i++) {
if (chain_type[family][i] != NULL &&
!nla_strcmp(nla, chain_type[family][i]->name))
return chain_type[family][i];
}
return NULL;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Arturo Borrero Gonzalez | 48 | 63.16% | 1 | 33.33% |
Pablo Neira Ayuso | 22 | 28.95% | 1 | 33.33% |
Patrick McHardy | 6 | 7.89% | 1 | 33.33% |
Total | 76 | 100.00% | 3 | 100.00% |
static const struct nf_chain_type *
nf_tables_chain_type_lookup(const struct nft_af_info *afi,
const struct nlattr *nla,
bool autoload)
{
const struct nf_chain_type *type;
type = __nf_tables_chain_type_lookup(afi->family, nla);
if (type != NULL)
return type;
#ifdef CONFIG_MODULES
if (autoload) {
nfnl_unlock(NFNL_SUBSYS_NFTABLES);
request_module("nft-chain-%u-%.*s", afi->family,
nla_len(nla), (const char *)nla_data(nla));
nfnl_lock(NFNL_SUBSYS_NFTABLES);
type = __nf_tables_chain_type_lookup(afi->family, nla);
if (type != NULL)
return ERR_PTR(-EAGAIN);
}
#endif
return ERR_PTR(-ENOENT);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Arturo Borrero Gonzalez | 95 | 75.40% | 1 | 25.00% |
Pablo Neira Ayuso | 22 | 17.46% | 2 | 50.00% |
Patrick McHardy | 9 | 7.14% | 1 | 25.00% |
Total | 126 | 100.00% | 4 | 100.00% |
static const struct nla_policy nft_table_policy[NFTA_TABLE_MAX + 1] = {
[NFTA_TABLE_NAME] = { .type = NLA_STRING,
.len = NFT_TABLE_MAXNAMELEN - 1 },
[NFTA_TABLE_FLAGS] = { .type = NLA_U32 },
};
static int nf_tables_fill_table_info(struct sk_buff *skb, struct net *net,
u32 portid, u32 seq, int event, u32 flags,
int family, const struct nft_table *table)
{
struct nlmsghdr *nlh;
struct nfgenmsg *nfmsg;
event |= NFNL_SUBSYS_NFTABLES << 8;
nlh = nlmsg_put(skb, portid, seq, event, sizeof(struct nfgenmsg), flags);
if (nlh == NULL)
goto nla_put_failure;
nfmsg = nlmsg_data(nlh);
nfmsg->nfgen_family = family;
nfmsg->version = NFNETLINK_V0;
nfmsg->res_id = htons(net->nft.base_seq & 0xffff);
if (nla_put_string(skb, NFTA_TABLE_NAME, table->name) ||
nla_put_be32(skb, NFTA_TABLE_FLAGS, htonl(table->flags)) ||
nla_put_be32(skb, NFTA_TABLE_USE, htonl(table->use)))
goto nla_put_failure;
nlmsg_end(skb, nlh);
return 0;
nla_put_failure:
nlmsg_trim(skb, nlh);
return -1;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Arturo Borrero Gonzalez | 109 | 59.24% | 1 | 16.67% |
Pablo Neira Ayuso | 72 | 39.13% | 4 | 66.67% |
Johannes Berg | 3 | 1.63% | 1 | 16.67% |
Total | 184 | 100.00% | 6 | 100.00% |
static void nf_tables_table_notify(const struct nft_ctx *ctx, int event)
{
struct sk_buff *skb;
int err;
if (!ctx->report &&
!nfnetlink_has_listeners(ctx->net, NFNLGRP_NFTABLES))
return;
skb = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL);
if (skb == NULL)
goto err;
err = nf_tables_fill_table_info(skb, ctx->net, ctx->portid, ctx->seq,
event, 0, ctx->afi->family, ctx->table);
if (err < 0) {
kfree_skb(skb);
goto err;
}
nfnetlink_send(skb, ctx->net, ctx->portid, NFNLGRP_NFTABLES,
ctx->report, GFP_KERNEL);
return;
err:
nfnetlink_set_err(ctx->net, ctx->portid, NFNLGRP_NFTABLES, -ENOBUFS);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Arturo Borrero Gonzalez | 109 | 73.65% | 1 | 16.67% |
Pablo Neira Ayuso | 29 | 19.59% | 4 | 66.67% |
Patrick McHardy | 10 | 6.76% | 1 | 16.67% |
Total | 148 | 100.00% | 6 | 100.00% |
static int nf_tables_dump_tables(struct sk_buff *skb,
struct netlink_callback *cb)
{
const struct nfgenmsg *nfmsg = nlmsg_data(cb->nlh);
const struct nft_af_info *afi;
const struct nft_table *table;
unsigned int idx = 0, s_idx = cb->args[0];
struct net *net = sock_net(skb->sk);
int family = nfmsg->nfgen_family;
rcu_read_lock();
cb->seq = net->nft.base_seq;
list_for_each_entry_rcu(afi, &net->nft.af_info, list) {
if (family != NFPROTO_UNSPEC && family != afi->family)
continue;
list_for_each_entry_rcu(table, &afi->tables, list) {
if (idx < s_idx)
goto cont;
if (idx > s_idx)
memset(&cb->args[1], 0,
sizeof(cb->args) - sizeof(cb->args[0]));
if (!nft_is_active(net, table))
continue;
if (nf_tables_fill_table_info(skb, net,
NETLINK_CB(cb->skb).portid,
cb->nlh->nlmsg_seq,
NFT_MSG_NEWTABLE,
NLM_F_MULTI,
afi->family, table) < 0)
goto done;
nl_dump_check_consistent(cb, nlmsg_hdr(skb));
cont:
idx++;
}
}
done:
rcu_read_unlock();
cb->args[0] = idx;
return skb->len;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Arturo Borrero Gonzalez | 153 | 61.20% | 1 | 16.67% |
Patrick McHardy | 69 | 27.60% | 1 | 16.67% |
Pablo Neira Ayuso | 28 | 11.20% | 4 | 66.67% |
Total | 250 | 100.00% | 6 | 100.00% |
static int nf_tables_gettable(struct net *net, struct sock *nlsk,
struct sk_buff *skb, const struct nlmsghdr *nlh,
const struct nlattr * const nla[])
{
const struct nfgenmsg *nfmsg = nlmsg_data(nlh);
u8 genmask = nft_genmask_cur(net);
const struct nft_af_info *afi;
const struct nft_table *table;
struct sk_buff *skb2;
int family = nfmsg->nfgen_family;
int err;
if (nlh->nlmsg_flags & NLM_F_DUMP) {
struct netlink_dump_control c = {
.dump = nf_tables_dump_tables,
};
return netlink_dump_start(nlsk, skb, nlh, &c);
}
afi = nf_tables_afinfo_lookup(net, family, false);
if (IS_ERR(afi))
return PTR_ERR(afi);
table = nf_tables_table_lookup(afi, nla[NFTA_TABLE_NAME], genmask);
if (IS_ERR(table))
return PTR_ERR(table);
skb2 = alloc_skb(NLMSG_GOODSIZE, GFP_KERNEL);
if (!skb2)
return -ENOMEM;
err = nf_tables_fill_table_info(skb2, net, NETLINK_CB(skb).portid,
nlh->nlmsg_seq, NFT_MSG_NEWTABLE, 0,
family, table);
if (err < 0)
goto err;
return nlmsg_unicast(nlsk, skb2, NETLINK_CB(skb).portid);
err:
kfree_skb(skb2);
return err;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Arturo Borrero Gonzalez | 153 | 62.20% | 1 | 11.11% |
Pablo Neira Ayuso | 49 | 19.92% | 6 | 66.67% |
Patrick McHardy | 44 | 17.89% | 2 | 22.22% |
Total | 246 | 100.00% | 9 | 100.00% |
static void _nf_tables_table_disable(struct net *net,
const struct nft_af_info *afi,
struct nft_table *table,
u32 cnt)
{
struct nft_chain *chain;
u32 i = 0;
list_for_each_entry(chain, &table->chains, list) {
if (!nft_is_active_next(net, chain))
continue;
if (!(chain->flags & NFT_BASE_CHAIN))
continue;
if (cnt && i++ == cnt)
break;
nf_unregister_net_hooks(net, nft_base_chain(chain)->ops,
afi->nops);
}
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Arturo Borrero Gonzalez | 29 | 30.85% | 1 | 14.29% |
Pablo Neira Ayuso | 25 | 26.60% | 4 | 57.14% |
Patrick McHardy | 21 | 22.34% | 1 | 14.29% |
Gao Feng | 19 | 20.21% | 1 | 14.29% |
Total | 94 | 100.00% | 7 | 100.00% |
static int nf_tables_table_enable(struct net *net,
const struct nft_af_info *afi