aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorPatrick McHardy <kaber@trash.net>2006-09-20 15:08:03 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2006-09-22 18:20:08 -0400
commit955b944293dd4c931ec866ebe19a6b2463b8f9a0 (patch)
tree2b3053116a8585810977383c3d28c60c0f7d0fb5 /net
parentedd5a329cf69c112882e03c8ab55e985062a5d2a (diff)
[NETFILTER]: PPTP conntrack: get rid of unnecessary byte order conversions
The conntrack structure contains the call ID in host byte order for no reason, get rid of back and forth conversions. Signed-off-by: Patrick McHardy <kaber@trash.net> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r--net/ipv4/netfilter/ip_conntrack_helper_pptp.c22
-rw-r--r--net/ipv4/netfilter/ip_nat_helper_pptp.c42
-rw-r--r--net/ipv4/netfilter/ip_nat_proto_gre.c2
3 files changed, 33 insertions, 33 deletions
diff --git a/net/ipv4/netfilter/ip_conntrack_helper_pptp.c b/net/ipv4/netfilter/ip_conntrack_helper_pptp.c
index 6c94dd5d476c..57637ca2b82c 100644
--- a/net/ipv4/netfilter/ip_conntrack_helper_pptp.c
+++ b/net/ipv4/netfilter/ip_conntrack_helper_pptp.c
@@ -201,8 +201,8 @@ static void pptp_destroy_siblings(struct ip_conntrack *ct)
201 /* try original (pns->pac) tuple */ 201 /* try original (pns->pac) tuple */
202 memcpy(&t, &ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple, sizeof(t)); 202 memcpy(&t, &ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple, sizeof(t));
203 t.dst.protonum = IPPROTO_GRE; 203 t.dst.protonum = IPPROTO_GRE;
204 t.src.u.gre.key = htons(ct->help.ct_pptp_info.pns_call_id); 204 t.src.u.gre.key = ct->help.ct_pptp_info.pns_call_id;
205 t.dst.u.gre.key = htons(ct->help.ct_pptp_info.pac_call_id); 205 t.dst.u.gre.key = ct->help.ct_pptp_info.pac_call_id;
206 206
207 if (!destroy_sibling_or_exp(&t)) 207 if (!destroy_sibling_or_exp(&t))
208 DEBUGP("failed to timeout original pns->pac ct/exp\n"); 208 DEBUGP("failed to timeout original pns->pac ct/exp\n");
@@ -210,8 +210,8 @@ static void pptp_destroy_siblings(struct ip_conntrack *ct)
210 /* try reply (pac->pns) tuple */ 210 /* try reply (pac->pns) tuple */
211 memcpy(&t, &ct->tuplehash[IP_CT_DIR_REPLY].tuple, sizeof(t)); 211 memcpy(&t, &ct->tuplehash[IP_CT_DIR_REPLY].tuple, sizeof(t));
212 t.dst.protonum = IPPROTO_GRE; 212 t.dst.protonum = IPPROTO_GRE;
213 t.src.u.gre.key = htons(ct->help.ct_pptp_info.pac_call_id); 213 t.src.u.gre.key = ct->help.ct_pptp_info.pac_call_id;
214 t.dst.u.gre.key = htons(ct->help.ct_pptp_info.pns_call_id); 214 t.dst.u.gre.key = ct->help.ct_pptp_info.pns_call_id;
215 215
216 if (!destroy_sibling_or_exp(&t)) 216 if (!destroy_sibling_or_exp(&t))
217 DEBUGP("failed to timeout reply pac->pns ct/exp\n"); 217 DEBUGP("failed to timeout reply pac->pns ct/exp\n");
@@ -419,9 +419,9 @@ pptp_inbound_pkt(struct sk_buff **pskb,
419 cid = &pptpReq->ocack.callID; 419 cid = &pptpReq->ocack.callID;
420 pcid = &pptpReq->ocack.peersCallID; 420 pcid = &pptpReq->ocack.peersCallID;
421 421
422 info->pac_call_id = ntohs(*cid); 422 info->pac_call_id = *cid;
423 423
424 if (htons(info->pns_call_id) != *pcid) { 424 if (info->pns_call_id != *pcid) {
425 DEBUGP("%s for unknown callid %u\n", 425 DEBUGP("%s for unknown callid %u\n",
426 pptp_msg_name[msg], ntohs(*pcid)); 426 pptp_msg_name[msg], ntohs(*pcid));
427 break; 427 break;
@@ -454,7 +454,7 @@ pptp_inbound_pkt(struct sk_buff **pskb,
454 pcid = &pptpReq->icack.peersCallID; 454 pcid = &pptpReq->icack.peersCallID;
455 DEBUGP("%s, PCID=%X\n", pptp_msg_name[msg], ntohs(*pcid)); 455 DEBUGP("%s, PCID=%X\n", pptp_msg_name[msg], ntohs(*pcid));
456 info->cstate = PPTP_CALL_IN_REQ; 456 info->cstate = PPTP_CALL_IN_REQ;
457 info->pac_call_id = ntohs(*pcid); 457 info->pac_call_id = *pcid;
458 break; 458 break;
459 459
460 case PPTP_IN_CALL_CONNECT: 460 case PPTP_IN_CALL_CONNECT:
@@ -478,7 +478,7 @@ pptp_inbound_pkt(struct sk_buff **pskb,
478 pcid = &pptpReq->iccon.peersCallID; 478 pcid = &pptpReq->iccon.peersCallID;
479 cid = &info->pac_call_id; 479 cid = &info->pac_call_id;
480 480
481 if (info->pns_call_id != ntohs(*pcid)) { 481 if (info->pns_call_id != *pcid) {
482 DEBUGP("%s for unknown CallID %u\n", 482 DEBUGP("%s for unknown CallID %u\n",
483 pptp_msg_name[msg], ntohs(*pcid)); 483 pptp_msg_name[msg], ntohs(*pcid));
484 break; 484 break;
@@ -595,7 +595,7 @@ pptp_outbound_pkt(struct sk_buff **pskb,
595 /* track PNS call id */ 595 /* track PNS call id */
596 cid = &pptpReq->ocreq.callID; 596 cid = &pptpReq->ocreq.callID;
597 DEBUGP("%s, CID=%X\n", pptp_msg_name[msg], ntohs(*cid)); 597 DEBUGP("%s, CID=%X\n", pptp_msg_name[msg], ntohs(*cid));
598 info->pns_call_id = ntohs(*cid); 598 info->pns_call_id = *cid;
599 break; 599 break;
600 case PPTP_IN_CALL_REPLY: 600 case PPTP_IN_CALL_REPLY:
601 if (reqlen < sizeof(_pptpReq.icack)) { 601 if (reqlen < sizeof(_pptpReq.icack)) {
@@ -615,7 +615,7 @@ pptp_outbound_pkt(struct sk_buff **pskb,
615 break; 615 break;
616 } 616 }
617 pcid = &pptpReq->icack.peersCallID; 617 pcid = &pptpReq->icack.peersCallID;
618 if (info->pac_call_id != ntohs(*pcid)) { 618 if (info->pac_call_id != *pcid) {
619 DEBUGP("%s for unknown call %u\n", 619 DEBUGP("%s for unknown call %u\n",
620 pptp_msg_name[msg], ntohs(*pcid)); 620 pptp_msg_name[msg], ntohs(*pcid));
621 break; 621 break;
@@ -623,7 +623,7 @@ pptp_outbound_pkt(struct sk_buff **pskb,
623 DEBUGP("%s, CID=%X\n", pptp_msg_name[msg], ntohs(*pcid)); 623 DEBUGP("%s, CID=%X\n", pptp_msg_name[msg], ntohs(*pcid));
624 /* part two of the three-way handshake */ 624 /* part two of the three-way handshake */
625 info->cstate = PPTP_CALL_IN_REP; 625 info->cstate = PPTP_CALL_IN_REP;
626 info->pns_call_id = ntohs(pptpReq->icack.callID); 626 info->pns_call_id = pptpReq->icack.callID;
627 break; 627 break;
628 628
629 case PPTP_CALL_CLEAR_REQUEST: 629 case PPTP_CALL_CLEAR_REQUEST:
diff --git a/net/ipv4/netfilter/ip_nat_helper_pptp.c b/net/ipv4/netfilter/ip_nat_helper_pptp.c
index 5dde1da1c300..6e8bd6b3431f 100644
--- a/net/ipv4/netfilter/ip_nat_helper_pptp.c
+++ b/net/ipv4/netfilter/ip_nat_helper_pptp.c
@@ -85,19 +85,17 @@ static void pptp_nat_expected(struct ip_conntrack *ct,
85 DEBUGP("we are PNS->PAC\n"); 85 DEBUGP("we are PNS->PAC\n");
86 /* therefore, build tuple for PAC->PNS */ 86 /* therefore, build tuple for PAC->PNS */
87 t.src.ip = master->tuplehash[IP_CT_DIR_REPLY].tuple.src.ip; 87 t.src.ip = master->tuplehash[IP_CT_DIR_REPLY].tuple.src.ip;
88 t.src.u.gre.key = htons(master->help.ct_pptp_info.pac_call_id); 88 t.src.u.gre.key = master->help.ct_pptp_info.pac_call_id;
89 t.dst.ip = master->tuplehash[IP_CT_DIR_REPLY].tuple.dst.ip; 89 t.dst.ip = master->tuplehash[IP_CT_DIR_REPLY].tuple.dst.ip;
90 t.dst.u.gre.key = htons(master->help.ct_pptp_info.pns_call_id); 90 t.dst.u.gre.key = master->help.ct_pptp_info.pns_call_id;
91 t.dst.protonum = IPPROTO_GRE; 91 t.dst.protonum = IPPROTO_GRE;
92 } else { 92 } else {
93 DEBUGP("we are PAC->PNS\n"); 93 DEBUGP("we are PAC->PNS\n");
94 /* build tuple for PNS->PAC */ 94 /* build tuple for PNS->PAC */
95 t.src.ip = master->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.ip; 95 t.src.ip = master->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.ip;
96 t.src.u.gre.key = 96 t.src.u.gre.key = master->nat.help.nat_pptp_info.pns_call_id;
97 htons(master->nat.help.nat_pptp_info.pns_call_id);
98 t.dst.ip = master->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.ip; 97 t.dst.ip = master->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.ip;
99 t.dst.u.gre.key = 98 t.dst.u.gre.key = master->nat.help.nat_pptp_info.pac_call_id;
100 htons(master->nat.help.nat_pptp_info.pac_call_id);
101 t.dst.protonum = IPPROTO_GRE; 99 t.dst.protonum = IPPROTO_GRE;
102 } 100 }
103 101
@@ -149,10 +147,11 @@ pptp_outbound_pkt(struct sk_buff **pskb,
149{ 147{
150 struct ip_ct_pptp_master *ct_pptp_info = &ct->help.ct_pptp_info; 148 struct ip_ct_pptp_master *ct_pptp_info = &ct->help.ct_pptp_info;
151 struct ip_nat_pptp *nat_pptp_info = &ct->nat.help.nat_pptp_info; 149 struct ip_nat_pptp *nat_pptp_info = &ct->nat.help.nat_pptp_info;
152 u_int16_t msg, new_callid; 150 u_int16_t msg;
151 __be16 new_callid;
153 unsigned int cid_off; 152 unsigned int cid_off;
154 153
155 new_callid = htons(ct_pptp_info->pns_call_id); 154 new_callid = ct_pptp_info->pns_call_id;
156 155
157 switch (msg = ntohs(ctlh->messageType)) { 156 switch (msg = ntohs(ctlh->messageType)) {
158 case PPTP_OUT_CALL_REQUEST: 157 case PPTP_OUT_CALL_REQUEST:
@@ -170,7 +169,7 @@ pptp_outbound_pkt(struct sk_buff **pskb,
170 new_callid = ct->tuplehash[IP_CT_DIR_REPLY].tuple.dst.u.tcp.port; 169 new_callid = ct->tuplehash[IP_CT_DIR_REPLY].tuple.dst.u.tcp.port;
171 170
172 /* save new call ID in ct info */ 171 /* save new call ID in ct info */
173 ct_pptp_info->pns_call_id = ntohs(new_callid); 172 ct_pptp_info->pns_call_id = new_callid;
174 break; 173 break;
175 case PPTP_IN_CALL_REPLY: 174 case PPTP_IN_CALL_REPLY:
176 cid_off = offsetof(union pptp_ctrl_union, icreq.callID); 175 cid_off = offsetof(union pptp_ctrl_union, icreq.callID);
@@ -235,14 +234,14 @@ pptp_exp_gre(struct ip_conntrack_expect *expect_orig,
235 234
236 /* alter expectation for PNS->PAC direction */ 235 /* alter expectation for PNS->PAC direction */
237 invert_tuplepr(&inv_t, &expect_orig->tuple); 236 invert_tuplepr(&inv_t, &expect_orig->tuple);
238 expect_orig->saved_proto.gre.key = htons(ct_pptp_info->pns_call_id); 237 expect_orig->saved_proto.gre.key = ct_pptp_info->pns_call_id;
239 expect_orig->tuple.src.u.gre.key = htons(nat_pptp_info->pns_call_id); 238 expect_orig->tuple.src.u.gre.key = nat_pptp_info->pns_call_id;
240 expect_orig->tuple.dst.u.gre.key = htons(ct_pptp_info->pac_call_id); 239 expect_orig->tuple.dst.u.gre.key = ct_pptp_info->pac_call_id;
241 expect_orig->dir = IP_CT_DIR_ORIGINAL; 240 expect_orig->dir = IP_CT_DIR_ORIGINAL;
242 inv_t.src.ip = reply_t->src.ip; 241 inv_t.src.ip = reply_t->src.ip;
243 inv_t.dst.ip = reply_t->dst.ip; 242 inv_t.dst.ip = reply_t->dst.ip;
244 inv_t.src.u.gre.key = htons(nat_pptp_info->pac_call_id); 243 inv_t.src.u.gre.key = nat_pptp_info->pac_call_id;
245 inv_t.dst.u.gre.key = htons(ct_pptp_info->pns_call_id); 244 inv_t.dst.u.gre.key = ct_pptp_info->pns_call_id;
246 245
247 if (!ip_conntrack_expect_related(expect_orig)) { 246 if (!ip_conntrack_expect_related(expect_orig)) {
248 DEBUGP("successfully registered expect\n"); 247 DEBUGP("successfully registered expect\n");
@@ -253,14 +252,14 @@ pptp_exp_gre(struct ip_conntrack_expect *expect_orig,
253 252
254 /* alter expectation for PAC->PNS direction */ 253 /* alter expectation for PAC->PNS direction */
255 invert_tuplepr(&inv_t, &expect_reply->tuple); 254 invert_tuplepr(&inv_t, &expect_reply->tuple);
256 expect_reply->saved_proto.gre.key = htons(nat_pptp_info->pns_call_id); 255 expect_reply->saved_proto.gre.key = nat_pptp_info->pns_call_id;
257 expect_reply->tuple.src.u.gre.key = htons(nat_pptp_info->pac_call_id); 256 expect_reply->tuple.src.u.gre.key = nat_pptp_info->pac_call_id;
258 expect_reply->tuple.dst.u.gre.key = htons(ct_pptp_info->pns_call_id); 257 expect_reply->tuple.dst.u.gre.key = ct_pptp_info->pns_call_id;
259 expect_reply->dir = IP_CT_DIR_REPLY; 258 expect_reply->dir = IP_CT_DIR_REPLY;
260 inv_t.src.ip = orig_t->src.ip; 259 inv_t.src.ip = orig_t->src.ip;
261 inv_t.dst.ip = orig_t->dst.ip; 260 inv_t.dst.ip = orig_t->dst.ip;
262 inv_t.src.u.gre.key = htons(nat_pptp_info->pns_call_id); 261 inv_t.src.u.gre.key = nat_pptp_info->pns_call_id;
263 inv_t.dst.u.gre.key = htons(ct_pptp_info->pac_call_id); 262 inv_t.dst.u.gre.key = ct_pptp_info->pac_call_id;
264 263
265 if (!ip_conntrack_expect_related(expect_reply)) { 264 if (!ip_conntrack_expect_related(expect_reply)) {
266 DEBUGP("successfully registered expect\n"); 265 DEBUGP("successfully registered expect\n");
@@ -297,10 +296,11 @@ pptp_inbound_pkt(struct sk_buff **pskb,
297 union pptp_ctrl_union *pptpReq) 296 union pptp_ctrl_union *pptpReq)
298{ 297{
299 struct ip_nat_pptp *nat_pptp_info = &ct->nat.help.nat_pptp_info; 298 struct ip_nat_pptp *nat_pptp_info = &ct->nat.help.nat_pptp_info;
300 u_int16_t msg, new_cid = 0, new_pcid; 299 u_int16_t msg, new_cid = 0;
300 __be16 new_pcid;
301 unsigned int pcid_off, cid_off = 0; 301 unsigned int pcid_off, cid_off = 0;
302 302
303 new_pcid = htons(nat_pptp_info->pns_call_id); 303 new_pcid = nat_pptp_info->pns_call_id;
304 304
305 switch (msg = ntohs(ctlh->messageType)) { 305 switch (msg = ntohs(ctlh->messageType)) {
306 case PPTP_OUT_CALL_REPLY: 306 case PPTP_OUT_CALL_REPLY:
diff --git a/net/ipv4/netfilter/ip_nat_proto_gre.c b/net/ipv4/netfilter/ip_nat_proto_gre.c
index a5226691f02c..bf91f9312b3c 100644
--- a/net/ipv4/netfilter/ip_nat_proto_gre.c
+++ b/net/ipv4/netfilter/ip_nat_proto_gre.c
@@ -67,7 +67,7 @@ gre_unique_tuple(struct ip_conntrack_tuple *tuple,
67 const struct ip_conntrack *conntrack) 67 const struct ip_conntrack *conntrack)
68{ 68{
69 static u_int16_t key; 69 static u_int16_t key;
70 u_int16_t *keyptr; 70 __be16 *keyptr;
71 unsigned int min, i, range_size; 71 unsigned int min, i, range_size;
72 72
73 if (maniptype == IP_NAT_MANIP_SRC) 73 if (maniptype == IP_NAT_MANIP_SRC)