[NETFILTER]: {ip,ip6}_tables: remove x_tables wrapper functions
[deliverable/linux.git] / net / ipv6 / netfilter / ip6t_owner.c
CommitLineData
1da177e4
LT
1/* Kernel module to match various things tied to sockets associated with
2 locally generated outgoing packets. */
3
4/* (C) 2000-2001 Marc Boucher <marc@mbsi.ca>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10
11#include <linux/module.h>
12#include <linux/skbuff.h>
13#include <linux/file.h>
b835996f 14#include <linux/rcupdate.h>
1da177e4
LT
15#include <net/sock.h>
16
17#include <linux/netfilter_ipv6/ip6t_owner.h>
18#include <linux/netfilter_ipv6/ip6_tables.h>
6709dbbb 19#include <linux/netfilter/x_tables.h>
1da177e4
LT
20
21MODULE_AUTHOR("Marc Boucher <marc@mbsi.ca>");
22MODULE_DESCRIPTION("IP6 tables owner matching module");
23MODULE_LICENSE("GPL");
24
1da177e4
LT
25
26static int
27match(const struct sk_buff *skb,
28 const struct net_device *in,
29 const struct net_device *out,
c4986734 30 const struct xt_match *match,
1da177e4
LT
31 const void *matchinfo,
32 int offset,
33 unsigned int protoff,
34 int *hotdrop)
35{
36 const struct ip6t_owner_info *info = matchinfo;
37
38 if (!skb->sk || !skb->sk->sk_socket || !skb->sk->sk_socket->file)
39 return 0;
40
f0daaa65
YK
41 if (info->match & IP6T_OWNER_UID) {
42 if ((skb->sk->sk_socket->file->f_uid != info->uid) ^
1da177e4
LT
43 !!(info->invert & IP6T_OWNER_UID))
44 return 0;
45 }
46
f0daaa65
YK
47 if (info->match & IP6T_OWNER_GID) {
48 if ((skb->sk->sk_socket->file->f_gid != info->gid) ^
1da177e4
LT
49 !!(info->invert & IP6T_OWNER_GID))
50 return 0;
51 }
52
1da177e4
LT
53 return 1;
54}
55
56static int
57checkentry(const char *tablename,
f0daaa65 58 const void *ip,
c4986734 59 const struct xt_match *match,
f0daaa65 60 void *matchinfo,
f0daaa65 61 unsigned int hook_mask)
1da177e4 62{
34b4a4a6
CH
63 const struct ip6t_owner_info *info = matchinfo;
64
f0daaa65 65 if (info->match & (IP6T_OWNER_PID | IP6T_OWNER_SID)) {
34b4a4a6
CH
66 printk("ipt_owner: pid and sid matching "
67 "not supported anymore\n");
1da177e4
LT
68 return 0;
69 }
1da177e4
LT
70 return 1;
71}
72
6709dbbb 73static struct xt_match owner_match = {
1da177e4 74 .name = "owner",
6709dbbb 75 .family = AF_INET6,
7f939713
PM
76 .match = match,
77 .matchsize = sizeof(struct ip6t_owner_info),
78 .hooks = (1 << NF_IP6_LOCAL_OUT) | (1 << NF_IP6_POST_ROUTING),
79 .checkentry = checkentry,
1da177e4
LT
80 .me = THIS_MODULE,
81};
82
65b4b4e8 83static int __init ip6t_owner_init(void)
1da177e4 84{
6709dbbb 85 return xt_register_match(&owner_match);
1da177e4
LT
86}
87
65b4b4e8 88static void __exit ip6t_owner_fini(void)
1da177e4 89{
6709dbbb 90 xt_unregister_match(&owner_match);
1da177e4
LT
91}
92
65b4b4e8
AM
93module_init(ip6t_owner_init);
94module_exit(ip6t_owner_fini);
This page took 0.189808 seconds and 5 git commands to generate.