diff options
author | Patrick McHardy <kaber@trash.net> | 2007-12-05 04:30:02 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-01-28 17:56:21 -0500 |
commit | ea3a66ff5ae41daa1d1aa789140a70415eaf7b46 (patch) | |
tree | 1b1b776165875bf9d271d476312df8356bce2bb1 /net | |
parent | 9d6023ab8b97f5074f9007c92d38fef9ae04e56b (diff) |
[NETFILTER]: nfnetlink_queue: use endianness-aware attribute functions
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/netfilter/nfnetlink_queue.c | 60 |
1 files changed, 23 insertions, 37 deletions
diff --git a/net/netfilter/nfnetlink_queue.c b/net/netfilter/nfnetlink_queue.c index de48fd3d8a38..436b442d4edc 100644 --- a/net/netfilter/nfnetlink_queue.c +++ b/net/netfilter/nfnetlink_queue.c | |||
@@ -215,7 +215,6 @@ nfqnl_build_packet_message(struct nfqnl_instance *queue, | |||
215 | struct sk_buff *entskb = entry->skb; | 215 | struct sk_buff *entskb = entry->skb; |
216 | struct net_device *indev; | 216 | struct net_device *indev; |
217 | struct net_device *outdev; | 217 | struct net_device *outdev; |
218 | __be32 tmp_uint; | ||
219 | 218 | ||
220 | size = NLMSG_ALIGN(sizeof(struct nfgenmsg)) | 219 | size = NLMSG_ALIGN(sizeof(struct nfgenmsg)) |
221 | + nla_total_size(sizeof(struct nfqnl_msg_packet_hdr)) | 220 | + nla_total_size(sizeof(struct nfqnl_msg_packet_hdr)) |
@@ -286,69 +285,57 @@ nfqnl_build_packet_message(struct nfqnl_instance *queue, | |||
286 | 285 | ||
287 | indev = entry->indev; | 286 | indev = entry->indev; |
288 | if (indev) { | 287 | if (indev) { |
289 | tmp_uint = htonl(indev->ifindex); | ||
290 | #ifndef CONFIG_BRIDGE_NETFILTER | 288 | #ifndef CONFIG_BRIDGE_NETFILTER |
291 | NLA_PUT(skb, NFQA_IFINDEX_INDEV, sizeof(tmp_uint), &tmp_uint); | 289 | NLA_PUT_BE32(skb, NFQA_IFINDEX_INDEV, htonl(indev->ifindex)); |
292 | #else | 290 | #else |
293 | if (entry->pf == PF_BRIDGE) { | 291 | if (entry->pf == PF_BRIDGE) { |
294 | /* Case 1: indev is physical input device, we need to | 292 | /* Case 1: indev is physical input device, we need to |
295 | * look for bridge group (when called from | 293 | * look for bridge group (when called from |
296 | * netfilter_bridge) */ | 294 | * netfilter_bridge) */ |
297 | NLA_PUT(skb, NFQA_IFINDEX_PHYSINDEV, sizeof(tmp_uint), | 295 | NLA_PUT_BE32(skb, NFQA_IFINDEX_PHYSINDEV, |
298 | &tmp_uint); | 296 | htonl(indev->ifindex)); |
299 | /* this is the bridge group "brX" */ | 297 | /* this is the bridge group "brX" */ |
300 | tmp_uint = htonl(indev->br_port->br->dev->ifindex); | 298 | NLA_PUT_BE32(skb, NFQA_IFINDEX_INDEV, |
301 | NLA_PUT(skb, NFQA_IFINDEX_INDEV, sizeof(tmp_uint), | 299 | htonl(indev->br_port->br->dev->ifindex)); |
302 | &tmp_uint); | ||
303 | } else { | 300 | } else { |
304 | /* Case 2: indev is bridge group, we need to look for | 301 | /* Case 2: indev is bridge group, we need to look for |
305 | * physical device (when called from ipv4) */ | 302 | * physical device (when called from ipv4) */ |
306 | NLA_PUT(skb, NFQA_IFINDEX_INDEV, sizeof(tmp_uint), | 303 | NLA_PUT_BE32(skb, NFQA_IFINDEX_INDEV, |
307 | &tmp_uint); | 304 | htonl(indev->ifindex)); |
308 | if (entskb->nf_bridge | 305 | if (entskb->nf_bridge && entskb->nf_bridge->physindev) |
309 | && entskb->nf_bridge->physindev) { | 306 | NLA_PUT_BE32(skb, NFQA_IFINDEX_PHYSINDEV, |
310 | tmp_uint = htonl(entskb->nf_bridge->physindev->ifindex); | 307 | htonl(entskb->nf_bridge->physindev->ifindex)); |
311 | NLA_PUT(skb, NFQA_IFINDEX_PHYSINDEV, | ||
312 | sizeof(tmp_uint), &tmp_uint); | ||
313 | } | ||
314 | } | 308 | } |
315 | #endif | 309 | #endif |
316 | } | 310 | } |
317 | 311 | ||
318 | if (outdev) { | 312 | if (outdev) { |
319 | tmp_uint = htonl(outdev->ifindex); | ||
320 | #ifndef CONFIG_BRIDGE_NETFILTER | 313 | #ifndef CONFIG_BRIDGE_NETFILTER |
321 | NLA_PUT(skb, NFQA_IFINDEX_OUTDEV, sizeof(tmp_uint), &tmp_uint); | 314 | NLA_PUT_BE32(skb, NFQA_IFINDEX_OUTDEV, htonl(outdev->ifindex)); |
322 | #else | 315 | #else |
323 | if (entry->pf == PF_BRIDGE) { | 316 | if (entry->pf == PF_BRIDGE) { |
324 | /* Case 1: outdev is physical output device, we need to | 317 | /* Case 1: outdev is physical output device, we need to |
325 | * look for bridge group (when called from | 318 | * look for bridge group (when called from |
326 | * netfilter_bridge) */ | 319 | * netfilter_bridge) */ |
327 | NLA_PUT(skb, NFQA_IFINDEX_PHYSOUTDEV, sizeof(tmp_uint), | 320 | NLA_PUT_BE32(skb, NFQA_IFINDEX_PHYSOUTDEV, |
328 | &tmp_uint); | 321 | htonl(outdev->ifindex)); |
329 | /* this is the bridge group "brX" */ | 322 | /* this is the bridge group "brX" */ |
330 | tmp_uint = htonl(outdev->br_port->br->dev->ifindex); | 323 | NLA_PUT_BE32(skb, NFQA_IFINDEX_OUTDEV, |
331 | NLA_PUT(skb, NFQA_IFINDEX_OUTDEV, sizeof(tmp_uint), | 324 | htonl(outdev->br_port->br->dev->ifindex)); |
332 | &tmp_uint); | ||
333 | } else { | 325 | } else { |
334 | /* Case 2: outdev is bridge group, we need to look for | 326 | /* Case 2: outdev is bridge group, we need to look for |
335 | * physical output device (when called from ipv4) */ | 327 | * physical output device (when called from ipv4) */ |
336 | NLA_PUT(skb, NFQA_IFINDEX_OUTDEV, sizeof(tmp_uint), | 328 | NLA_PUT_BE32(skb, NFQA_IFINDEX_OUTDEV, |
337 | &tmp_uint); | 329 | htonl(outdev->ifindex)); |
338 | if (entskb->nf_bridge | 330 | if (entskb->nf_bridge && entskb->nf_bridge->physoutdev) |
339 | && entskb->nf_bridge->physoutdev) { | 331 | NLA_PUT_BE32(skb, NFQA_IFINDEX_PHYSOUTDEV, |
340 | tmp_uint = htonl(entskb->nf_bridge->physoutdev->ifindex); | 332 | htonl(entskb->nf_bridge->physoutdev->ifindex)); |
341 | NLA_PUT(skb, NFQA_IFINDEX_PHYSOUTDEV, | ||
342 | sizeof(tmp_uint), &tmp_uint); | ||
343 | } | ||
344 | } | 333 | } |
345 | #endif | 334 | #endif |
346 | } | 335 | } |
347 | 336 | ||
348 | if (entskb->mark) { | 337 | if (entskb->mark) |
349 | tmp_uint = htonl(entskb->mark); | 338 | NLA_PUT_BE32(skb, NFQA_MARK, htonl(entskb->mark)); |
350 | NLA_PUT(skb, NFQA_MARK, sizeof(u_int32_t), &tmp_uint); | ||
351 | } | ||
352 | 339 | ||
353 | if (indev && entskb->dev) { | 340 | if (indev && entskb->dev) { |
354 | struct nfqnl_msg_packet_hw phw; | 341 | struct nfqnl_msg_packet_hw phw; |
@@ -670,8 +657,7 @@ nfqnl_recv_verdict(struct sock *ctnl, struct sk_buff *skb, | |||
670 | } | 657 | } |
671 | 658 | ||
672 | if (nfqa[NFQA_MARK]) | 659 | if (nfqa[NFQA_MARK]) |
673 | entry->skb->mark = ntohl(*(__be32 *) | 660 | entry->skb->mark = ntohl(nla_get_be32(nfqa[NFQA_MARK])); |
674 | nla_data(nfqa[NFQA_MARK])); | ||
675 | 661 | ||
676 | nf_reinject(entry, verdict); | 662 | nf_reinject(entry, verdict); |
677 | return 0; | 663 | return 0; |