]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - net/ipv4/netfilter/ip_nat_helper_pptp.c
[SK_BUFF]: Introduce ipv6_hdr(), remove skb->nh.ipv6h
[linux-2.6-omap-h63xx.git] / net / ipv4 / netfilter / ip_nat_helper_pptp.c
index 0f5e753b481defc3b7bf15a9002e597bb8e1fbd8..24ce4a5023d76b0d3b9cb2abcef6e8c5740e357e 100644 (file)
@@ -51,7 +51,7 @@
 
 #define IP_NAT_PPTP_VERSION "3.0"
 
-#define REQ_CID(req, off)              (*(u_int16_t *)((char *)(req) + (off)))
+#define REQ_CID(req, off)              (*(__be16 *)((char *)(req) + (off)))
 
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Harald Welte <laforge@gnumonks.org>");
@@ -101,7 +101,7 @@ static void pptp_nat_expected(struct ip_conntrack *ct,
 
        DEBUGP("trying to unexpect other dir: ");
        DUMP_TUPLE(&t);
-       other_exp = ip_conntrack_expect_find(&t);
+       other_exp = ip_conntrack_expect_find_get(&t);
        if (other_exp) {
                ip_conntrack_unexpect_related(other_exp);
                ip_conntrack_expect_put(other_exp);
@@ -172,7 +172,7 @@ pptp_outbound_pkt(struct sk_buff **pskb,
                ct_pptp_info->pns_call_id = new_callid;
                break;
        case PPTP_IN_CALL_REPLY:
-               cid_off = offsetof(union pptp_ctrl_union, icreq.callID);
+               cid_off = offsetof(union pptp_ctrl_union, icack.callID);
                break;
        case PPTP_CALL_CLEAR_REQUEST:
                cid_off = offsetof(union pptp_ctrl_union, clrreq.callID);
@@ -202,89 +202,37 @@ pptp_outbound_pkt(struct sk_buff **pskb,
 
        /* mangle packet */
        if (ip_nat_mangle_tcp_packet(pskb, ct, ctinfo,
-                                    cid_off + sizeof(struct pptp_pkt_hdr) +
-                                    sizeof(struct PptpControlHeader),
-                                    sizeof(new_callid), (char *)&new_callid,
-                                    sizeof(new_callid)) == 0)
+                                    cid_off + sizeof(struct pptp_pkt_hdr) +
+                                    sizeof(struct PptpControlHeader),
+                                    sizeof(new_callid), (char *)&new_callid,
+                                    sizeof(new_callid)) == 0)
                return NF_DROP;
 
        return NF_ACCEPT;
 }
 
-static int
+static void
 pptp_exp_gre(struct ip_conntrack_expect *expect_orig,
             struct ip_conntrack_expect *expect_reply)
 {
-       struct ip_ct_pptp_master *ct_pptp_info =
-                               &expect_orig->master->help.ct_pptp_info;
-       struct ip_nat_pptp *nat_pptp_info =
-                               &expect_orig->master->nat.help.nat_pptp_info;
-
        struct ip_conntrack *ct = expect_orig->master;
-
-       struct ip_conntrack_tuple inv_t;
-       struct ip_conntrack_tuple *orig_t, *reply_t;
+       struct ip_ct_pptp_master *ct_pptp_info = &ct->help.ct_pptp_info;
+       struct ip_nat_pptp *nat_pptp_info = &ct->nat.help.nat_pptp_info;
 
        /* save original PAC call ID in nat_info */
        nat_pptp_info->pac_call_id = ct_pptp_info->pac_call_id;
 
-       /* alter expectation */
-       orig_t = &ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple;
-       reply_t = &ct->tuplehash[IP_CT_DIR_REPLY].tuple;
-
        /* alter expectation for PNS->PAC direction */
-       invert_tuplepr(&inv_t, &expect_orig->tuple);
        expect_orig->saved_proto.gre.key = ct_pptp_info->pns_call_id;
        expect_orig->tuple.src.u.gre.key = nat_pptp_info->pns_call_id;
        expect_orig->tuple.dst.u.gre.key = ct_pptp_info->pac_call_id;
        expect_orig->dir = IP_CT_DIR_ORIGINAL;
-       inv_t.src.ip = reply_t->src.ip;
-       inv_t.dst.ip = reply_t->dst.ip;
-       inv_t.src.u.gre.key = nat_pptp_info->pac_call_id;
-       inv_t.dst.u.gre.key = ct_pptp_info->pns_call_id;
-
-       if (!ip_conntrack_expect_related(expect_orig)) {
-               DEBUGP("successfully registered expect\n");
-       } else {
-               DEBUGP("can't expect_related(expect_orig)\n");
-               return 1;
-       }
 
        /* alter expectation for PAC->PNS direction */
-       invert_tuplepr(&inv_t, &expect_reply->tuple);
        expect_reply->saved_proto.gre.key = nat_pptp_info->pns_call_id;
        expect_reply->tuple.src.u.gre.key = nat_pptp_info->pac_call_id;
        expect_reply->tuple.dst.u.gre.key = ct_pptp_info->pns_call_id;
        expect_reply->dir = IP_CT_DIR_REPLY;
-       inv_t.src.ip = orig_t->src.ip;
-       inv_t.dst.ip = orig_t->dst.ip;
-       inv_t.src.u.gre.key = nat_pptp_info->pns_call_id;
-       inv_t.dst.u.gre.key = ct_pptp_info->pac_call_id;
-
-       if (!ip_conntrack_expect_related(expect_reply)) {
-               DEBUGP("successfully registered expect\n");
-       } else {
-               DEBUGP("can't expect_related(expect_reply)\n");
-               ip_conntrack_unexpect_related(expect_orig);
-               return 1;
-       }
-
-       if (ip_ct_gre_keymap_add(ct, &expect_reply->tuple, 0) < 0) {
-               DEBUGP("can't register original keymap\n");
-               ip_conntrack_unexpect_related(expect_orig);
-               ip_conntrack_unexpect_related(expect_reply);
-               return 1;
-       }
-
-       if (ip_ct_gre_keymap_add(ct, &inv_t, 1) < 0) {
-               DEBUGP("can't register reply keymap\n");
-               ip_conntrack_unexpect_related(expect_orig);
-               ip_conntrack_unexpect_related(expect_reply);
-               ip_ct_gre_keymap_destroy(ct);
-               return 1;
-       }
-
-       return 0;
 }
 
 /* inbound packets == from PAC to PNS */
@@ -345,7 +293,7 @@ pptp_inbound_pkt(struct sk_buff **pskb,
                ntohs(REQ_CID(pptpReq, pcid_off)), ntohs(new_pcid));
 
        if (ip_nat_mangle_tcp_packet(pskb, ct, ctinfo,
-                                    pcid_off + sizeof(struct pptp_pkt_hdr) +
+                                    pcid_off + sizeof(struct pptp_pkt_hdr) +
                                     sizeof(struct PptpControlHeader),
                                     sizeof(new_pcid), (char *)&new_pcid,
                                     sizeof(new_pcid)) == 0)
@@ -367,17 +315,17 @@ static int __init ip_nat_helper_pptp_init(void)
        if (ret < 0)
                return ret;
 
-       BUG_ON(ip_nat_pptp_hook_outbound);
-       ip_nat_pptp_hook_outbound = &pptp_outbound_pkt;
+       BUG_ON(rcu_dereference(ip_nat_pptp_hook_outbound));
+       rcu_assign_pointer(ip_nat_pptp_hook_outbound, pptp_outbound_pkt);
 
-       BUG_ON(ip_nat_pptp_hook_inbound);
-       ip_nat_pptp_hook_inbound = &pptp_inbound_pkt;
+       BUG_ON(rcu_dereference(ip_nat_pptp_hook_inbound));
+       rcu_assign_pointer(ip_nat_pptp_hook_inbound, pptp_inbound_pkt);
 
-       BUG_ON(ip_nat_pptp_hook_exp_gre);
-       ip_nat_pptp_hook_exp_gre = &pptp_exp_gre;
+       BUG_ON(rcu_dereference(ip_nat_pptp_hook_exp_gre));
+       rcu_assign_pointer(ip_nat_pptp_hook_exp_gre, pptp_exp_gre);
 
-       BUG_ON(ip_nat_pptp_hook_expectfn);
-       ip_nat_pptp_hook_expectfn = &pptp_nat_expected;
+       BUG_ON(rcu_dereference(ip_nat_pptp_hook_expectfn));
+       rcu_assign_pointer(ip_nat_pptp_hook_expectfn, pptp_nat_expected);
 
        printk("ip_nat_pptp version %s loaded\n", IP_NAT_PPTP_VERSION);
        return 0;
@@ -387,14 +335,13 @@ static void __exit ip_nat_helper_pptp_fini(void)
 {
        DEBUGP("cleanup_module\n" );
 
-       ip_nat_pptp_hook_expectfn = NULL;
-       ip_nat_pptp_hook_exp_gre = NULL;
-       ip_nat_pptp_hook_inbound = NULL;
-       ip_nat_pptp_hook_outbound = NULL;
+       rcu_assign_pointer(ip_nat_pptp_hook_expectfn, NULL);
+       rcu_assign_pointer(ip_nat_pptp_hook_exp_gre, NULL);
+       rcu_assign_pointer(ip_nat_pptp_hook_inbound, NULL);
+       rcu_assign_pointer(ip_nat_pptp_hook_outbound, NULL);
+       synchronize_rcu();
 
        ip_nat_proto_gre_fini();
-       /* Make sure noone calls it, meanwhile */
-       synchronize_net();
 
        printk("ip_nat_pptp version %s unloaded\n", IP_NAT_PPTP_VERSION);
 }