1 /* Kernel module to match various things tied to sockets associated with
2 locally generated outgoing packets. */
4 /* (C) 2000-2001 Marc Boucher <marc@mbsi.ca>
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.
11 #include <linux/module.h>
12 #include <linux/skbuff.h>
13 #include <linux/file.h>
16 #include <linux/netfilter_ipv6/ip6t_owner.h>
17 #include <linux/netfilter_ipv6/ip6_tables.h>
19 MODULE_AUTHOR("Marc Boucher <marc@mbsi.ca>");
20 MODULE_DESCRIPTION("IP6 tables owner matching module");
21 MODULE_LICENSE("GPL");
25 match(const struct sk_buff *skb,
26 const struct net_device *in,
27 const struct net_device *out,
28 const void *matchinfo,
33 const struct ip6t_owner_info *info = matchinfo;
35 if (!skb->sk || !skb->sk->sk_socket || !skb->sk->sk_socket->file)
38 if(info->match & IP6T_OWNER_UID) {
39 if((skb->sk->sk_socket->file->f_uid != info->uid) ^
40 !!(info->invert & IP6T_OWNER_UID))
44 if(info->match & IP6T_OWNER_GID) {
45 if((skb->sk->sk_socket->file->f_gid != info->gid) ^
46 !!(info->invert & IP6T_OWNER_GID))
54 checkentry(const char *tablename,
55 const struct ip6t_ip6 *ip,
57 unsigned int matchsize,
58 unsigned int hook_mask)
60 const struct ip6t_owner_info *info = matchinfo;
63 & ~((1 << NF_IP6_LOCAL_OUT) | (1 << NF_IP6_POST_ROUTING))) {
64 printk("ip6t_owner: only valid for LOCAL_OUT or POST_ROUTING.\n");
68 if (matchsize != IP6T_ALIGN(sizeof(struct ip6t_owner_info)))
71 if (info->match & (IP6T_OWNER_PID|IP6T_OWNER_SID)) {
72 printk("ipt_owner: pid and sid matching "
73 "not supported anymore\n");
80 static struct ip6t_match owner_match = {
83 .checkentry = &checkentry,
87 static int __init init(void)
89 return ip6t_register_match(&owner_match);
92 static void __exit fini(void)
94 ip6t_unregister_match(&owner_match);