History

netfilter: prepare xt_cgroup for multi revisions

xt_cgroup will grow cgroup2 path based match. Postfix existing symbols with _v0 and prepare for multi revision registration.

Tejun Heo committed 10 years ago

Commit 4ec8ff01 parent a4ec8002 files · +20 −18Browse files

Unified · Split

2 files
  1. include/uapi/linux/netfilter/xt_cgroup.h +1 −1
  2. net/netfilter/xt_cgroup.c +19 −17
include/uapi/linux/netfilter/xt_cgroup.h+1−1
@@ -3,7 +3,7 @@ · 2 unmodified lines
33
44 #include <linux/types.h>
55
6−struct xt_cgroup_info {
6+struct xt_cgroup_info_v0 {
77 __u32 id;
88 __u32 invert;
99 };
net/netfilter/xt_cgroup.c+19−17
@@ -24,9 +24,9 @@ MODULE_DESCRIPTION("Xtables: process control group matching"); · 23 unmodified lines
2424 MODULE_ALIAS("ipt_cgroup");
2525 MODULE_ALIAS("ip6t_cgroup");
2626
27−static int cgroup_mt_check(const struct xt_mtchk_param *par)
27+static int cgroup_mt_check_v0(const struct xt_mtchk_param *par)
2828 {
29− struct xt_cgroup_info *info = par->matchinfo;
29+ struct xt_cgroup_info_v0 *info = par->matchinfo;
3030
3131 if (info->invert & ~1)
3232 return -EINVAL;
@@ -35,9 +35,9 @@ static int cgroup_mt_check(const struct xt_mtchk_param *par) · 2 unmodified lines
3535 }
3636
3737 static bool
38−cgroup_mt(const struct sk_buff *skb, struct xt_action_param *par)
38+cgroup_mt_v0(const struct sk_buff *skb, struct xt_action_param *par)
3939 {
40− const struct xt_cgroup_info *info = par->matchinfo;
40+ const struct xt_cgroup_info_v0 *info = par->matchinfo;
4141
4242 if (skb->sk == NULL || !sk_fullsock(skb->sk))
4343 return false;
@@ -46,27 +46,29 @@ cgroup_mt(const struct sk_buff *skb, struct xt_action_param *par) · 2 unmodified lines
4646 info->invert;
4747 }
4848
49−static struct xt_match cgroup_mt_reg __read_mostly = {
50− .name = "cgroup",
51− .revision = 0,
52− .family = NFPROTO_UNSPEC,
53− .checkentry = cgroup_mt_check,
54− .match = cgroup_mt,
55− .matchsize = sizeof(struct xt_cgroup_info),
56− .me = THIS_MODULE,
57− .hooks = (1 << NF_INET_LOCAL_OUT) |
58− (1 << NF_INET_POST_ROUTING) |
59− (1 << NF_INET_LOCAL_IN),
49+static struct xt_match cgroup_mt_reg[] __read_mostly = {
50+ {
51+ .name = "cgroup",
52+ .revision = 0,
53+ .family = NFPROTO_UNSPEC,
54+ .checkentry = cgroup_mt_check_v0,
55+ .match = cgroup_mt_v0,
56+ .matchsize = sizeof(struct xt_cgroup_info_v0),
57+ .me = THIS_MODULE,
58+ .hooks = (1 << NF_INET_LOCAL_OUT) |
59+ (1 << NF_INET_POST_ROUTING) |
60+ (1 << NF_INET_LOCAL_IN),
61+ },
6062 };
6163
6264 static int __init cgroup_mt_init(void)
6365 {
64− return xt_register_match(&cgroup_mt_reg);
66+ return xt_register_matches(cgroup_mt_reg, ARRAY_SIZE(cgroup_mt_reg));
6567 }
6668
6769 static void __exit cgroup_mt_exit(void)
6870 {
69− xt_unregister_match(&cgroup_mt_reg);
71+ xt_unregister_matches(cgroup_mt_reg, ARRAY_SIZE(cgroup_mt_reg));
7072 }
7173
7274 module_init(cgroup_mt_init);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t