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
3 3
4#include <linux/types.h>4#include <linux/types.h>
5 5
6struct xt_cgroup_info {6struct xt_cgroup_info_v0 {
7 __u32 id;7 __u32 id;
8 __u32 invert;8 __u32 invert;
9};9};
net/netfilter/xt_cgroup.c+19−17
@@ -24,9 +24,9 @@ MODULE_DESCRIPTION("Xtables: process control group matching"); · 23 unmodified lines
24MODULE_ALIAS("ipt_cgroup");24MODULE_ALIAS("ipt_cgroup");
25MODULE_ALIAS("ip6t_cgroup");25MODULE_ALIAS("ip6t_cgroup");
26 26
27static int cgroup_mt_check(const struct xt_mtchk_param *par)27static int cgroup_mt_check_v0(const struct xt_mtchk_param *par)
28{28{
29 struct xt_cgroup_info *info = par->matchinfo;29 struct xt_cgroup_info_v0 *info = par->matchinfo;
30 30
31 if (info->invert & ~1)31 if (info->invert & ~1)
32 return -EINVAL;32 return -EINVAL;
@@ -35,9 +35,9 @@ static int cgroup_mt_check(const struct xt_mtchk_param *par) · 2 unmodified lines
35}35}
36 36
37static bool37static bool
38cgroup_mt(const struct sk_buff *skb, struct xt_action_param *par)38cgroup_mt_v0(const struct sk_buff *skb, struct xt_action_param *par)
39{39{
40 const struct xt_cgroup_info *info = par->matchinfo;40 const struct xt_cgroup_info_v0 *info = par->matchinfo;
41 41
42 if (skb->sk == NULL || !sk_fullsock(skb->sk))42 if (skb->sk == NULL || !sk_fullsock(skb->sk))
43 return false;43 return false;
@@ -46,27 +46,29 @@ cgroup_mt(const struct sk_buff *skb, struct xt_action_param *par) · 2 unmodified lines
46 info->invert;46 info->invert;
47}47}
48 48
49static struct xt_match cgroup_mt_reg __read_mostly = {49static struct xt_match cgroup_mt_reg[] __read_mostly = {
50 .name = "cgroup",50 {
51 .revision = 0,51 .name = "cgroup",
52 .family = NFPROTO_UNSPEC,52 .revision = 0,
53 .checkentry = cgroup_mt_check,53 .family = NFPROTO_UNSPEC,
54 .match = cgroup_mt,54 .checkentry = cgroup_mt_check_v0,
55 .matchsize = sizeof(struct xt_cgroup_info),55 .match = cgroup_mt_v0,
56 .me = THIS_MODULE,56 .matchsize = sizeof(struct xt_cgroup_info_v0),
57 .hooks = (1 << NF_INET_LOCAL_OUT) |57 .me = THIS_MODULE,
58 (1 << NF_INET_POST_ROUTING) |58 .hooks = (1 << NF_INET_LOCAL_OUT) |
59 (1 << NF_INET_LOCAL_IN),59 (1 << NF_INET_POST_ROUTING) |
60 (1 << NF_INET_LOCAL_IN),
61 },
60};62};
61 63
62static int __init cgroup_mt_init(void)64static int __init cgroup_mt_init(void)
63{65{
64 return xt_register_match(&cgroup_mt_reg);66 return xt_register_matches(cgroup_mt_reg, ARRAY_SIZE(cgroup_mt_reg));
65}67}
66 68
67static void __exit cgroup_mt_exit(void)69static void __exit cgroup_mt_exit(void)
68{70{
69 xt_unregister_match(&cgroup_mt_reg);71 xt_unregister_matches(cgroup_mt_reg, ARRAY_SIZE(cgroup_mt_reg));
70}72}
71 73
72module_init(cgroup_mt_init);74module_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