]> err.no Git - linux-2.6/commitdiff
[NETFILTER]: Export ip6_masked_addrcmp, don't pass IPv6 addresses on stack
authorPatrick McHardy <kaber@trash.net>
Thu, 5 Jan 2006 20:21:34 +0000 (12:21 -0800)
committerDavid S. Miller <davem@davemloft.net>
Thu, 5 Jan 2006 20:21:34 +0000 (12:21 -0800)
Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/linux/netfilter_ipv6/ip6_tables.h
net/ipv6/netfilter/ip6_tables.c

index a291cb76ef18a17a7a01dd47a1fd72e5647379a5..c163ba31aab7bc82745ab8d27f54ff7932ea4f21 100644 (file)
@@ -476,6 +476,10 @@ extern int ip6t_ext_hdr(u8 nexthdr);
 extern int ipv6_find_hdr(const struct sk_buff *skb, unsigned int *offset,
                         int target, unsigned short *fragoff);
 
+extern int ip6_masked_addrcmp(const struct in6_addr *addr1,
+                             const struct in6_addr *mask,
+                             const struct in6_addr *addr2);
+
 #define IP6T_ALIGN(s) (((s) + (__alignof__(struct ip6t_entry)-1)) & ~(__alignof__(struct ip6t_entry)-1))
 
 #endif /*__KERNEL__*/
index 13b1a525b92c67ea31f82e35490a347cd35346cf..925b42d48347c9ffc5285ba6ff83460652f8be85 100644 (file)
@@ -119,13 +119,14 @@ static LIST_HEAD(ip6t_tables);
 #define up(x) do { printk("UP:%u:" #x "\n", __LINE__); up(x); } while(0)
 #endif
 
-static int ip6_masked_addrcmp(struct in6_addr addr1, struct in6_addr mask,
-                             struct in6_addr addr2)
+int
+ip6_masked_addrcmp(const struct in6_addr *addr1, const struct in6_addr *mask,
+                   const struct in6_addr *addr2)
 {
        int i;
        for( i = 0; i < 16; i++){
-               if((addr1.s6_addr[i] & mask.s6_addr[i]) != 
-                  (addr2.s6_addr[i] & mask.s6_addr[i]))
+               if((addr1->s6_addr[i] & mask->s6_addr[i]) != 
+                  (addr2->s6_addr[i] & mask->s6_addr[i]))
                        return 1;
        }
        return 0;
@@ -159,10 +160,10 @@ ip6_packet_match(const struct sk_buff *skb,
 
 #define FWINV(bool,invflg) ((bool) ^ !!(ip6info->invflags & invflg))
 
-       if (FWINV(ip6_masked_addrcmp(ipv6->saddr,ip6info->smsk,ip6info->src),
-                 IP6T_INV_SRCIP)
-           || FWINV(ip6_masked_addrcmp(ipv6->daddr,ip6info->dmsk,ip6info->dst),
-                    IP6T_INV_DSTIP)) {
+       if (FWINV(ip6_masked_addrcmp(&ipv6->saddr, &ip6info->smsk,
+                                    &ip6info->src), IP6T_INV_SRCIP)
+           || FWINV(ip6_masked_addrcmp(&ipv6->daddr, &ip6info->dmsk,
+                                       &ip6info->dst), IP6T_INV_DSTIP)) {
                dprintf("Source or dest mismatch.\n");
 /*
                dprintf("SRC: %u. Mask: %u. Target: %u.%s\n", ip->saddr,
@@ -2131,6 +2132,7 @@ EXPORT_SYMBOL(ip6t_register_target);
 EXPORT_SYMBOL(ip6t_unregister_target);
 EXPORT_SYMBOL(ip6t_ext_hdr);
 EXPORT_SYMBOL(ipv6_find_hdr);
+EXPORT_SYMBOL(ip6_masked_addrcmp);
 
 module_init(init);
 module_exit(fini);