]> bbs.cooldavid.org Git - net-next-2.6.git/blobdiff - net/ipv4/netfilter.c
[NETNS]: Add netns parameter to inet_(dev_)add_type.
[net-next-2.6.git] / net / ipv4 / netfilter.c
index 5539debf49735de2ea50105b507139ed1d35799d..0ed843ed420a9febbfe5c9278edcad7ce1abe782 100644 (file)
@@ -7,6 +7,7 @@
 #include <net/route.h>
 #include <net/xfrm.h>
 #include <net/ip.h>
+#include <net/netfilter/nf_queue.h>
 
 /* route_me_harder function, used by iptable_nat, iptable_mangle + ip_queue */
 int ip_route_me_harder(struct sk_buff *skb, unsigned addr_type)
@@ -18,12 +19,12 @@ int ip_route_me_harder(struct sk_buff *skb, unsigned addr_type)
        unsigned int hh_len;
        unsigned int type;
 
-       type = inet_addr_type(iph->saddr);
+       type = inet_addr_type(&init_net, iph->saddr);
        if (addr_type == RTN_UNSPEC)
                addr_type = type;
 
        /* some non-standard hacks like ipt_REJECT.c:send_reset() can cause
-        * packets with foreign saddr to appear on the NF_IP_LOCAL_OUT hook.
+        * packets with foreign saddr to appear on the NF_INET_LOCAL_OUT hook.
         */
        if (addr_type == RTN_LOCAL) {
                fl.nl_u.ip4_u.daddr = iph->daddr;
@@ -122,11 +123,12 @@ struct ip_rt_info {
        u_int8_t tos;
 };
 
-static void nf_ip_saveroute(const struct sk_buff *skb, struct nf_info *info)
+static void nf_ip_saveroute(const struct sk_buff *skb,
+                           struct nf_queue_entry *entry)
 {
-       struct ip_rt_info *rt_info = nf_info_reroute(info);
+       struct ip_rt_info *rt_info = nf_queue_entry_reroute(entry);
 
-       if (info->hook == NF_IP_LOCAL_OUT) {
+       if (entry->hook == NF_INET_LOCAL_OUT) {
                const struct iphdr *iph = ip_hdr(skb);
 
                rt_info->tos = iph->tos;
@@ -135,11 +137,12 @@ static void nf_ip_saveroute(const struct sk_buff *skb, struct nf_info *info)
        }
 }
 
-static int nf_ip_reroute(struct sk_buff *skb, const struct nf_info *info)
+static int nf_ip_reroute(struct sk_buff *skb,
+                        const struct nf_queue_entry *entry)
 {
-       const struct ip_rt_info *rt_info = nf_info_reroute(info);
+       const struct ip_rt_info *rt_info = nf_queue_entry_reroute(entry);
 
-       if (info->hook == NF_IP_LOCAL_OUT) {
+       if (entry->hook == NF_INET_LOCAL_OUT) {
                const struct iphdr *iph = ip_hdr(skb);
 
                if (!(iph->tos == rt_info->tos
@@ -158,7 +161,7 @@ __sum16 nf_ip_checksum(struct sk_buff *skb, unsigned int hook,
 
        switch (skb->ip_summed) {
        case CHECKSUM_COMPLETE:
-               if (hook != NF_IP_PRE_ROUTING && hook != NF_IP_LOCAL_IN)
+               if (hook != NF_INET_PRE_ROUTING && hook != NF_INET_LOCAL_IN)
                        break;
                if ((protocol == 0 && !csum_fold(skb->csum)) ||
                    !csum_tcpudp_magic(iph->saddr, iph->daddr,
@@ -182,9 +185,15 @@ __sum16 nf_ip_checksum(struct sk_buff *skb, unsigned int hook,
 
 EXPORT_SYMBOL(nf_ip_checksum);
 
-static struct nf_afinfo nf_ip_afinfo = {
+static int nf_ip_route(struct dst_entry **dst, struct flowi *fl)
+{
+       return ip_route_output_key((struct rtable **)dst, fl);
+}
+
+static const struct nf_afinfo nf_ip_afinfo = {
        .family         = AF_INET,
        .checksum       = nf_ip_checksum,
+       .route          = nf_ip_route,
        .saveroute      = nf_ip_saveroute,
        .reroute        = nf_ip_reroute,
        .route_key_size = sizeof(struct ip_rt_info),