xt_cgroup will grow cgroup2 path based match. Postfix existing symbols with _v0 and prepare for multi revision registration.
Unified · Split
| @@ -3,7 +3,7 @@ · 2 unmodified lines | |||
| 3 | 3 | ||
| 4 | #include <linux/types.h> | 4 | #include <linux/types.h> |
| 5 | 5 | ||
| 6 | struct xt_cgroup_info { | 6 | struct xt_cgroup_info_v0 { |
| 7 | __u32 id; | 7 | __u32 id; |
| 8 | __u32 invert; | 8 | __u32 invert; |
| 9 | }; | 9 | }; |
| @@ -24,9 +24,9 @@ MODULE_DESCRIPTION("Xtables: process control group matching"); · 23 unmodified lines | |||
| 24 | MODULE_ALIAS("ipt_cgroup"); | 24 | MODULE_ALIAS("ipt_cgroup"); |
| 25 | MODULE_ALIAS("ip6t_cgroup"); | 25 | MODULE_ALIAS("ip6t_cgroup"); |
| 26 | 26 | ||
| 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) |
| 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 | ||
| 37 | static bool | 37 | 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) |
| 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 | ||
| 49 | static struct xt_match cgroup_mt_reg __read_mostly = { | 49 | static 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 | ||
| 62 | static int __init cgroup_mt_init(void) | 64 | static 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 | ||
| 67 | static void __exit cgroup_mt_exit(void) | 69 | static 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 | ||
| 72 | module_init(cgroup_mt_init); | 74 | module_init(cgroup_mt_init); |