aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@g5.osdl.org>2006-09-29 02:03:42 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-09-29 02:03:42 -0400
commit3dcbbcda7c5b77c400791b26facd6593c5b176e0 (patch)
tree2e7b844c4d450cf43810a6ed0ddd5c702c245a88 /net
parentc972398b7871d9fb58c6a317786065a7cc6ca4be (diff)
parent6fbe59b9569b2c8d5522d182263935c6c86fc40a (diff)
Merge master.kernel.org:/pub/scm/linux/kernel/git/davem/net-2.6
* master.kernel.org:/pub/scm/linux/kernel/git/davem/net-2.6: (160 commits) [ETHTOOL]: Remove some entries from non-root command list. [Bluetooth]: Fix section mismatch of bt_sysfs_cleanup() [Bluetooth]: Don't update disconnect timer for incoming connections [ETHTOOL]: let mortals use ethtool [NetLabel]: add audit support for configuration changes [TCP]: Fix and simplify microsecond rtt sampling [TCP] tcp-lp: prevent chance for oops [SUNRPC]: Remove unnecessary check in net/sunrpc/svcsock.c [IPVS] bug: endianness breakage in ip_vs_ftp [IPVS]: ipvs annotations [NETFILTER]: h323 annotations [NETFILTER]: ipt annotations [NETFILTER]: NAT annotations [NETFILTER]: conntrack annotations [NETFILTER]: netfilter misc annotations [NET]: Annotate dst_ops protocol [NET]: is it Andy or Andi ?? [IPVS]: Make sure ip_vs_ftp ports are valid: module_param_array approach [IPVS]: Reverse valid ip_vs_ftp ports fix: port check approach [IrDA] stir4200: removing undocumented bits handling ...
Diffstat (limited to 'net')
-rw-r--r--net/802/tr.c12
-rw-r--r--net/Kconfig2
-rw-r--r--net/appletalk/ddp.c79
-rw-r--r--net/atm/mpc.c13
-rw-r--r--net/atm/mpoa_caches.c12
-rw-r--r--net/bluetooth/af_bluetooth.c2
-rw-r--r--net/bluetooth/bnep/core.c26
-rw-r--r--net/bluetooth/hci_conn.c39
-rw-r--r--net/bluetooth/hci_core.c3
-rw-r--r--net/bluetooth/hci_event.c26
-rw-r--r--net/bluetooth/hci_sysfs.c135
-rw-r--r--net/bluetooth/hidp/core.c23
-rw-r--r--net/bluetooth/rfcomm/core.c2
-rw-r--r--net/bluetooth/rfcomm/tty.c21
-rw-r--r--net/bridge/netfilter/ebt_arpreply.c2
-rw-r--r--net/core/dev.c14
-rw-r--r--net/core/ethtool.c32
-rw-r--r--net/core/neighbour.c2
-rw-r--r--net/core/pktgen.c321
-rw-r--r--net/core/rtnetlink.c2
-rw-r--r--net/core/utils.c2
-rw-r--r--net/dccp/ipv4.c2
-rw-r--r--net/ethernet/eth.c2
-rw-r--r--net/ipv4/af_inet.c8
-rw-r--r--net/ipv4/arp.c40
-rw-r--r--net/ipv4/cipso_ipv4.c8
-rw-r--r--net/ipv4/datagram.c2
-rw-r--r--net/ipv4/devinet.c42
-rw-r--r--net/ipv4/fib_frontend.c37
-rw-r--r--net/ipv4/fib_hash.c22
-rw-r--r--net/ipv4/fib_lookup.h6
-rw-r--r--net/ipv4/fib_rules.c24
-rw-r--r--net/ipv4/fib_semantics.c33
-rw-r--r--net/ipv4/fib_trie.c12
-rw-r--r--net/ipv4/icmp.c10
-rw-r--r--net/ipv4/igmp.c68
-rw-r--r--net/ipv4/inet_connection_sock.c12
-rw-r--r--net/ipv4/inet_diag.c12
-rw-r--r--net/ipv4/inet_hashtables.c12
-rw-r--r--net/ipv4/inetpeer.c4
-rw-r--r--net/ipv4/ip_fragment.c15
-rw-r--r--net/ipv4/ip_options.c26
-rw-r--r--net/ipv4/ip_output.c6
-rw-r--r--net/ipv4/ip_sockglue.c4
-rw-r--r--net/ipv4/ipcomp.c2
-rw-r--r--net/ipv4/ipmr.c4
-rw-r--r--net/ipv4/ipvs/ip_vs_conn.c24
-rw-r--r--net/ipv4/ipvs/ip_vs_core.c14
-rw-r--r--net/ipv4/ipvs/ip_vs_ctl.c26
-rw-r--r--net/ipv4/ipvs/ip_vs_dh.c4
-rw-r--r--net/ipv4/ipvs/ip_vs_ftp.c27
-rw-r--r--net/ipv4/ipvs/ip_vs_lblc.c8
-rw-r--r--net/ipv4/ipvs/ip_vs_lblcr.c8
-rw-r--r--net/ipv4/ipvs/ip_vs_proto.c2
-rw-r--r--net/ipv4/ipvs/ip_vs_proto_tcp.c10
-rw-r--r--net/ipv4/ipvs/ip_vs_proto_udp.c14
-rw-r--r--net/ipv4/ipvs/ip_vs_sh.c4
-rw-r--r--net/ipv4/ipvs/ip_vs_sync.c18
-rw-r--r--net/ipv4/ipvs/ip_vs_xmit.c2
-rw-r--r--net/ipv4/multipath_wrandom.c14
-rw-r--r--net/ipv4/netfilter.c4
-rw-r--r--net/ipv4/netfilter/arp_tables.c2
-rw-r--r--net/ipv4/netfilter/ip_conntrack_amanda.c6
-rw-r--r--net/ipv4/netfilter/ip_conntrack_core.c12
-rw-r--r--net/ipv4/netfilter/ip_conntrack_ftp.c6
-rw-r--r--net/ipv4/netfilter/ip_conntrack_helper_h323.c84
-rw-r--r--net/ipv4/netfilter/ip_conntrack_helper_pptp.c4
-rw-r--r--net/ipv4/netfilter/ip_conntrack_irc.c5
-rw-r--r--net/ipv4/netfilter/ip_conntrack_netbios_ns.c12
-rw-r--r--net/ipv4/netfilter/ip_conntrack_netlink.c82
-rw-r--r--net/ipv4/netfilter/ip_conntrack_proto_icmp.c4
-rw-r--r--net/ipv4/netfilter/ip_conntrack_proto_sctp.c2
-rw-r--r--net/ipv4/netfilter/ip_conntrack_proto_tcp.c6
-rw-r--r--net/ipv4/netfilter/ip_conntrack_sip.c16
-rw-r--r--net/ipv4/netfilter/ip_conntrack_tftp.c8
-rw-r--r--net/ipv4/netfilter/ip_nat_core.c14
-rw-r--r--net/ipv4/netfilter/ip_nat_ftp.c10
-rw-r--r--net/ipv4/netfilter/ip_nat_helper.c39
-rw-r--r--net/ipv4/netfilter/ip_nat_helper_h323.c16
-rw-r--r--net/ipv4/netfilter/ip_nat_helper_pptp.c2
-rw-r--r--net/ipv4/netfilter/ip_nat_proto_icmp.c2
-rw-r--r--net/ipv4/netfilter/ip_nat_proto_tcp.c10
-rw-r--r--net/ipv4/netfilter/ip_nat_proto_udp.c10
-rw-r--r--net/ipv4/netfilter/ip_nat_rule.c6
-rw-r--r--net/ipv4/netfilter/ip_nat_sip.c8
-rw-r--r--net/ipv4/netfilter/ip_nat_snmp_basic.c2
-rw-r--r--net/ipv4/netfilter/ip_nat_standalone.c2
-rw-r--r--net/ipv4/netfilter/ipt_CLUSTERIP.c14
-rw-r--r--net/ipv4/netfilter/ipt_ECN.c12
-rw-r--r--net/ipv4/netfilter/ipt_MASQUERADE.c2
-rw-r--r--net/ipv4/netfilter/ipt_NETMAP.c2
-rw-r--r--net/ipv4/netfilter/ipt_REDIRECT.c2
-rw-r--r--net/ipv4/netfilter/ipt_REJECT.c4
-rw-r--r--net/ipv4/netfilter/ipt_SAME.c3
-rw-r--r--net/ipv4/netfilter/ipt_TCPMSS.c17
-rw-r--r--net/ipv4/netfilter/ipt_TOS.c4
-rw-r--r--net/ipv4/netfilter/ipt_TTL.c4
-rw-r--r--net/ipv4/netfilter/ipt_addrtype.c2
-rw-r--r--net/ipv4/netfilter/ipt_hashlimit.c16
-rw-r--r--net/ipv4/netfilter/ipt_recent.c15
-rw-r--r--net/ipv4/netfilter/iptable_mangle.c2
-rw-r--r--net/ipv4/raw.c4
-rw-r--r--net/ipv4/route.c99
-rw-r--r--net/ipv4/tcp_input.c32
-rw-r--r--net/ipv4/tcp_ipv4.c8
-rw-r--r--net/ipv4/tcp_lp.c4
-rw-r--r--net/ipv4/tcp_output.c12
-rw-r--r--net/ipv4/udp.c32
-rw-r--r--net/ipv4/xfrm4_input.c4
-rw-r--r--net/ipv4/xfrm4_policy.c6
-rw-r--r--net/ipv4/xfrm4_state.c4
-rw-r--r--net/ipv6/addrconf.c4
-rw-r--r--net/ipv6/af_inet6.c2
-rw-r--r--net/ipv6/inet6_hashtables.c8
-rw-r--r--net/ipv6/ipcomp6.c4
-rw-r--r--net/ipv6/ipv6_sockglue.c3
-rw-r--r--net/ipv6/tcp_ipv6.c2
-rw-r--r--net/ipv6/xfrm6_input.c4
-rw-r--r--net/ipv6/xfrm6_state.c4
-rw-r--r--net/ipv6/xfrm6_tunnel.c2
-rw-r--r--net/irda/af_irda.c12
-rw-r--r--net/irda/ircomm/ircomm_lmp.c4
-rw-r--r--net/irda/iriap.c9
-rw-r--r--net/irda/iriap_event.c2
-rw-r--r--net/irda/irlan/irlan_common.c46
-rw-r--r--net/irda/irlan/irlan_provider.c12
-rw-r--r--net/irda/irlap_frame.c59
-rw-r--r--net/irda/irlmp.c2
-rw-r--r--net/irda/irttp.c14
-rw-r--r--net/key/af_key.c8
-rw-r--r--net/netlabel/netlabel_cipso_v4.c43
-rw-r--r--net/netlabel/netlabel_domainhash.c54
-rw-r--r--net/netlabel/netlabel_domainhash.h6
-rw-r--r--net/netlabel/netlabel_mgmt.c14
-rw-r--r--net/netlabel/netlabel_unlabeled.c36
-rw-r--r--net/netlabel/netlabel_user.c91
-rw-r--r--net/netlabel/netlabel_user.h6
-rw-r--r--net/sched/cls_api.c4
-rw-r--r--net/sched/cls_basic.c2
-rw-r--r--net/sched/sch_api.c16
-rw-r--r--net/sched/sch_generic.c66
-rw-r--r--net/sched/sch_htb.c2
-rw-r--r--net/sunrpc/auth.c12
-rw-r--r--net/sunrpc/auth_gss/auth_gss.c33
-rw-r--r--net/sunrpc/auth_gss/gss_krb5_seal.c2
-rw-r--r--net/sunrpc/auth_gss/gss_krb5_wrap.c4
-rw-r--r--net/sunrpc/auth_gss/svcauth_gss.c82
-rw-r--r--net/sunrpc/auth_null.c8
-rw-r--r--net/sunrpc/auth_unix.c10
-rw-r--r--net/sunrpc/clnt.c23
-rw-r--r--net/sunrpc/pmap_clnt.c6
-rw-r--r--net/sunrpc/svc.c52
-rw-r--r--net/sunrpc/svcauth.c4
-rw-r--r--net/sunrpc/svcauth_unix.c38
-rw-r--r--net/sunrpc/svcsock.c16
-rw-r--r--net/sunrpc/xdr.c54
-rw-r--r--net/sunrpc/xprt.c4
-rw-r--r--net/sunrpc/xprtsock.c3
-rw-r--r--net/xfrm/xfrm_hash.h4
-rw-r--r--net/xfrm/xfrm_input.c8
-rw-r--r--net/xfrm/xfrm_state.c37
161 files changed, 1846 insertions, 1131 deletions
diff --git a/net/802/tr.c b/net/802/tr.c
index d7d8f40c4fed..829deb41ce81 100644
--- a/net/802/tr.c
+++ b/net/802/tr.c
@@ -164,7 +164,7 @@ static int tr_rebuild_header(struct sk_buff *skb)
164 */ 164 */
165 165
166 if(trllc->ethertype != htons(ETH_P_IP)) { 166 if(trllc->ethertype != htons(ETH_P_IP)) {
167 printk("tr_rebuild_header: Don't know how to resolve type %04X addresses ?\n",(unsigned int)htons(trllc->ethertype)); 167 printk("tr_rebuild_header: Don't know how to resolve type %04X addresses ?\n", ntohs(trllc->ethertype));
168 return 0; 168 return 0;
169 } 169 }
170 170
@@ -186,7 +186,7 @@ static int tr_rebuild_header(struct sk_buff *skb)
186 * it via SNAP. 186 * it via SNAP.
187 */ 187 */
188 188
189unsigned short tr_type_trans(struct sk_buff *skb, struct net_device *dev) 189__be16 tr_type_trans(struct sk_buff *skb, struct net_device *dev)
190{ 190{
191 191
192 struct trh_hdr *trh=(struct trh_hdr *)skb->data; 192 struct trh_hdr *trh=(struct trh_hdr *)skb->data;
@@ -229,15 +229,15 @@ unsigned short tr_type_trans(struct sk_buff *skb, struct net_device *dev)
229 */ 229 */
230 230
231 if (trllc->dsap == EXTENDED_SAP && 231 if (trllc->dsap == EXTENDED_SAP &&
232 (trllc->ethertype == ntohs(ETH_P_IP) || 232 (trllc->ethertype == htons(ETH_P_IP) ||
233 trllc->ethertype == ntohs(ETH_P_IPV6) || 233 trllc->ethertype == htons(ETH_P_IPV6) ||
234 trllc->ethertype == ntohs(ETH_P_ARP))) 234 trllc->ethertype == htons(ETH_P_ARP)))
235 { 235 {
236 skb_pull(skb, sizeof(struct trllc)); 236 skb_pull(skb, sizeof(struct trllc));
237 return trllc->ethertype; 237 return trllc->ethertype;
238 } 238 }
239 239
240 return ntohs(ETH_P_TR_802_2); 240 return htons(ETH_P_TR_802_2);
241} 241}
242 242
243/* 243/*
diff --git a/net/Kconfig b/net/Kconfig
index 6528a935622c..a81aca43932f 100644
--- a/net/Kconfig
+++ b/net/Kconfig
@@ -231,7 +231,7 @@ config NET_TCPPROBE
231 TCP congestion avoidance modules. If you don't understand 231 TCP congestion avoidance modules. If you don't understand
232 what was just said, you don't need it: say N. 232 what was just said, you don't need it: say N.
233 233
234 Documentation on how to use the packet generator can be found 234 Documentation on how to use TCP connection probing can be found
235 at http://linux-net.osdl.org/index.php/TcpProbe 235 at http://linux-net.osdl.org/index.php/TcpProbe
236 236
237 To compile this code as a module, choose M here: the 237 To compile this code as a module, choose M here: the
diff --git a/net/appletalk/ddp.c b/net/appletalk/ddp.c
index 96dc6bb52d14..708e2e0371af 100644
--- a/net/appletalk/ddp.c
+++ b/net/appletalk/ddp.c
@@ -1002,7 +1002,7 @@ static unsigned long atalk_sum_skb(const struct sk_buff *skb, int offset,
1002 return sum; 1002 return sum;
1003} 1003}
1004 1004
1005static unsigned short atalk_checksum(const struct sk_buff *skb, int len) 1005static __be16 atalk_checksum(const struct sk_buff *skb, int len)
1006{ 1006{
1007 unsigned long sum; 1007 unsigned long sum;
1008 1008
@@ -1010,7 +1010,7 @@ static unsigned short atalk_checksum(const struct sk_buff *skb, int len)
1010 sum = atalk_sum_skb(skb, 4, len-4, 0); 1010 sum = atalk_sum_skb(skb, 4, len-4, 0);
1011 1011
1012 /* Use 0xFFFF for 0. 0 itself means none */ 1012 /* Use 0xFFFF for 0. 0 itself means none */
1013 return sum ? htons((unsigned short)sum) : 0xFFFF; 1013 return sum ? htons((unsigned short)sum) : htons(0xFFFF);
1014} 1014}
1015 1015
1016static struct proto ddp_proto = { 1016static struct proto ddp_proto = {
@@ -1289,7 +1289,7 @@ static int handle_ip_over_ddp(struct sk_buff *skb)
1289#endif 1289#endif
1290 1290
1291static void atalk_route_packet(struct sk_buff *skb, struct net_device *dev, 1291static void atalk_route_packet(struct sk_buff *skb, struct net_device *dev,
1292 struct ddpehdr *ddp, struct ddpebits *ddphv, 1292 struct ddpehdr *ddp, __u16 len_hops,
1293 int origlen) 1293 int origlen)
1294{ 1294{
1295 struct atalk_route *rt; 1295 struct atalk_route *rt;
@@ -1317,10 +1317,12 @@ static void atalk_route_packet(struct sk_buff *skb, struct net_device *dev,
1317 1317
1318 /* Route the packet */ 1318 /* Route the packet */
1319 rt = atrtr_find(&ta); 1319 rt = atrtr_find(&ta);
1320 if (!rt || ddphv->deh_hops == DDP_MAXHOPS) 1320 /* increment hops count */
1321 len_hops += 1 << 10;
1322 if (!rt || !(len_hops & (15 << 10)))
1321 goto free_it; 1323 goto free_it;
1324
1322 /* FIXME: use skb->cb to be able to use shared skbs */ 1325 /* FIXME: use skb->cb to be able to use shared skbs */
1323 ddphv->deh_hops++;
1324 1326
1325 /* 1327 /*
1326 * Route goes through another gateway, so set the target to the 1328 * Route goes through another gateway, so set the target to the
@@ -1335,11 +1337,10 @@ static void atalk_route_packet(struct sk_buff *skb, struct net_device *dev,
1335 /* Fix up skb->len field */ 1337 /* Fix up skb->len field */
1336 skb_trim(skb, min_t(unsigned int, origlen, 1338 skb_trim(skb, min_t(unsigned int, origlen,
1337 (rt->dev->hard_header_len + 1339 (rt->dev->hard_header_len +
1338 ddp_dl->header_length + ddphv->deh_len))); 1340 ddp_dl->header_length + (len_hops & 1023))));
1339 1341
1340 /* Mend the byte order */
1341 /* FIXME: use skb->cb to be able to use shared skbs */ 1342 /* FIXME: use skb->cb to be able to use shared skbs */
1342 *((__u16 *)ddp) = ntohs(*((__u16 *)ddphv)); 1343 ddp->deh_len_hops = htons(len_hops);
1343 1344
1344 /* 1345 /*
1345 * Send the buffer onwards 1346 * Send the buffer onwards
@@ -1394,7 +1395,7 @@ static int atalk_rcv(struct sk_buff *skb, struct net_device *dev,
1394 struct atalk_iface *atif; 1395 struct atalk_iface *atif;
1395 struct sockaddr_at tosat; 1396 struct sockaddr_at tosat;
1396 int origlen; 1397 int origlen;
1397 struct ddpebits ddphv; 1398 __u16 len_hops;
1398 1399
1399 /* Don't mangle buffer if shared */ 1400 /* Don't mangle buffer if shared */
1400 if (!(skb = skb_share_check(skb, GFP_ATOMIC))) 1401 if (!(skb = skb_share_check(skb, GFP_ATOMIC)))
@@ -1406,16 +1407,11 @@ static int atalk_rcv(struct sk_buff *skb, struct net_device *dev,
1406 1407
1407 ddp = ddp_hdr(skb); 1408 ddp = ddp_hdr(skb);
1408 1409
1409 /* 1410 len_hops = ntohs(ddp->deh_len_hops);
1410 * Fix up the length field [Ok this is horrible but otherwise
1411 * I end up with unions of bit fields and messy bit field order
1412 * compiler/endian dependencies..]
1413 */
1414 *((__u16 *)&ddphv) = ntohs(*((__u16 *)ddp));
1415 1411
1416 /* Trim buffer in case of stray trailing data */ 1412 /* Trim buffer in case of stray trailing data */
1417 origlen = skb->len; 1413 origlen = skb->len;
1418 skb_trim(skb, min_t(unsigned int, skb->len, ddphv.deh_len)); 1414 skb_trim(skb, min_t(unsigned int, skb->len, len_hops & 1023));
1419 1415
1420 /* 1416 /*
1421 * Size check to see if ddp->deh_len was crap 1417 * Size check to see if ddp->deh_len was crap
@@ -1430,7 +1426,7 @@ static int atalk_rcv(struct sk_buff *skb, struct net_device *dev,
1430 * valid for net byte orders all over the networking code... 1426 * valid for net byte orders all over the networking code...
1431 */ 1427 */
1432 if (ddp->deh_sum && 1428 if (ddp->deh_sum &&
1433 atalk_checksum(skb, ddphv.deh_len) != ddp->deh_sum) 1429 atalk_checksum(skb, len_hops & 1023) != ddp->deh_sum)
1434 /* Not a valid AppleTalk frame - dustbin time */ 1430 /* Not a valid AppleTalk frame - dustbin time */
1435 goto freeit; 1431 goto freeit;
1436 1432
@@ -1444,7 +1440,7 @@ static int atalk_rcv(struct sk_buff *skb, struct net_device *dev,
1444 /* Not ours, so we route the packet via the correct 1440 /* Not ours, so we route the packet via the correct
1445 * AppleTalk iface 1441 * AppleTalk iface
1446 */ 1442 */
1447 atalk_route_packet(skb, dev, ddp, &ddphv, origlen); 1443 atalk_route_packet(skb, dev, ddp, len_hops, origlen);
1448 goto out; 1444 goto out;
1449 } 1445 }
1450 1446
@@ -1489,7 +1485,7 @@ static int ltalk_rcv(struct sk_buff *skb, struct net_device *dev,
1489 /* Find our address */ 1485 /* Find our address */
1490 struct atalk_addr *ap = atalk_find_dev_addr(dev); 1486 struct atalk_addr *ap = atalk_find_dev_addr(dev);
1491 1487
1492 if (!ap || skb->len < sizeof(struct ddpshdr)) 1488 if (!ap || skb->len < sizeof(__be16) || skb->len > 1023)
1493 goto freeit; 1489 goto freeit;
1494 1490
1495 /* Don't mangle buffer if shared */ 1491 /* Don't mangle buffer if shared */
@@ -1519,11 +1515,8 @@ static int ltalk_rcv(struct sk_buff *skb, struct net_device *dev,
1519 /* 1515 /*
1520 * Not sure about this bit... 1516 * Not sure about this bit...
1521 */ 1517 */
1522 ddp->deh_len = skb->len; 1518 /* Non routable, so force a drop if we slip up later */
1523 ddp->deh_hops = DDP_MAXHOPS; /* Non routable, so force a drop 1519 ddp->deh_len_hops = htons(skb->len + (DDP_MAXHOPS << 10));
1524 if we slip up later */
1525 /* Mend the byte order */
1526 *((__u16 *)ddp) = htons(*((__u16 *)ddp));
1527 } 1520 }
1528 skb->h.raw = skb->data; 1521 skb->h.raw = skb->data;
1529 1522
@@ -1622,16 +1615,7 @@ static int atalk_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr
1622 SOCK_DEBUG(sk, "SK %p: Begin build.\n", sk); 1615 SOCK_DEBUG(sk, "SK %p: Begin build.\n", sk);
1623 1616
1624 ddp = (struct ddpehdr *)skb_put(skb, sizeof(struct ddpehdr)); 1617 ddp = (struct ddpehdr *)skb_put(skb, sizeof(struct ddpehdr));
1625 ddp->deh_pad = 0; 1618 ddp->deh_len_hops = htons(len + sizeof(*ddp));
1626 ddp->deh_hops = 0;
1627 ddp->deh_len = len + sizeof(*ddp);
1628 /*
1629 * Fix up the length field [Ok this is horrible but otherwise
1630 * I end up with unions of bit fields and messy bit field order
1631 * compiler/endian dependencies..
1632 */
1633 *((__u16 *)ddp) = ntohs(*((__u16 *)ddp));
1634
1635 ddp->deh_dnet = usat->sat_addr.s_net; 1619 ddp->deh_dnet = usat->sat_addr.s_net;
1636 ddp->deh_snet = at->src_net; 1620 ddp->deh_snet = at->src_net;
1637 ddp->deh_dnode = usat->sat_addr.s_node; 1621 ddp->deh_dnode = usat->sat_addr.s_node;
@@ -1712,8 +1696,8 @@ static int atalk_recvmsg(struct kiocb *iocb, struct socket *sock, struct msghdr
1712 struct sockaddr_at *sat = (struct sockaddr_at *)msg->msg_name; 1696 struct sockaddr_at *sat = (struct sockaddr_at *)msg->msg_name;
1713 struct ddpehdr *ddp; 1697 struct ddpehdr *ddp;
1714 int copied = 0; 1698 int copied = 0;
1699 int offset = 0;
1715 int err = 0; 1700 int err = 0;
1716 struct ddpebits ddphv;
1717 struct sk_buff *skb = skb_recv_datagram(sk, flags & ~MSG_DONTWAIT, 1701 struct sk_buff *skb = skb_recv_datagram(sk, flags & ~MSG_DONTWAIT,
1718 flags & MSG_DONTWAIT, &err); 1702 flags & MSG_DONTWAIT, &err);
1719 if (!skb) 1703 if (!skb)
@@ -1721,25 +1705,18 @@ static int atalk_recvmsg(struct kiocb *iocb, struct socket *sock, struct msghdr
1721 1705
1722 /* FIXME: use skb->cb to be able to use shared skbs */ 1706 /* FIXME: use skb->cb to be able to use shared skbs */
1723 ddp = ddp_hdr(skb); 1707 ddp = ddp_hdr(skb);
1724 *((__u16 *)&ddphv) = ntohs(*((__u16 *)ddp)); 1708 copied = ntohs(ddp->deh_len_hops) & 1023;
1725 1709
1726 if (sk->sk_type == SOCK_RAW) { 1710 if (sk->sk_type != SOCK_RAW) {
1727 copied = ddphv.deh_len; 1711 offset = sizeof(*ddp);
1728 if (copied > size) { 1712 copied -= offset;
1729 copied = size; 1713 }
1730 msg->msg_flags |= MSG_TRUNC;
1731 }
1732 1714
1733 err = skb_copy_datagram_iovec(skb, 0, msg->msg_iov, copied); 1715 if (copied > size) {
1734 } else { 1716 copied = size;
1735 copied = ddphv.deh_len - sizeof(*ddp); 1717 msg->msg_flags |= MSG_TRUNC;
1736 if (copied > size) {
1737 copied = size;
1738 msg->msg_flags |= MSG_TRUNC;
1739 }
1740 err = skb_copy_datagram_iovec(skb, sizeof(*ddp),
1741 msg->msg_iov, copied);
1742 } 1718 }
1719 err = skb_copy_datagram_iovec(skb, offset, msg->msg_iov, copied);
1743 1720
1744 if (!err) { 1721 if (!err) {
1745 if (sat) { 1722 if (sat) {
diff --git a/net/atm/mpc.c b/net/atm/mpc.c
index b87c2a88bdce..0d2b994af511 100644
--- a/net/atm/mpc.c
+++ b/net/atm/mpc.c
@@ -560,7 +560,6 @@ static int atm_mpoa_vcc_attach(struct atm_vcc *vcc, void __user *arg)
560 struct atmmpc_ioc ioc_data; 560 struct atmmpc_ioc ioc_data;
561 in_cache_entry *in_entry; 561 in_cache_entry *in_entry;
562 uint32_t ipaddr; 562 uint32_t ipaddr;
563 unsigned char *ip;
564 563
565 bytes_left = copy_from_user(&ioc_data, arg, sizeof(struct atmmpc_ioc)); 564 bytes_left = copy_from_user(&ioc_data, arg, sizeof(struct atmmpc_ioc));
566 if (bytes_left != 0) { 565 if (bytes_left != 0) {
@@ -583,9 +582,8 @@ static int atm_mpoa_vcc_attach(struct atm_vcc *vcc, void __user *arg)
583 if (in_entry != NULL) mpc->in_ops->put(in_entry); 582 if (in_entry != NULL) mpc->in_ops->put(in_entry);
584 return -EINVAL; 583 return -EINVAL;
585 } 584 }
586 ip = (unsigned char*)&in_entry->ctrl_info.in_dst_ip;
587 printk("mpoa: (%s) mpc_vcc_attach: attaching ingress SVC, entry = %u.%u.%u.%u\n", 585 printk("mpoa: (%s) mpc_vcc_attach: attaching ingress SVC, entry = %u.%u.%u.%u\n",
588 mpc->dev->name, ip[0], ip[1], ip[2], ip[3]); 586 mpc->dev->name, NIPQUAD(in_entry->ctrl_info.in_dst_ip));
589 in_entry->shortcut = vcc; 587 in_entry->shortcut = vcc;
590 mpc->in_ops->put(in_entry); 588 mpc->in_ops->put(in_entry);
591 } else { 589 } else {
@@ -616,10 +614,8 @@ static void mpc_vcc_close(struct atm_vcc *vcc, struct net_device *dev)
616 dprintk("mpoa: (%s) mpc_vcc_close:\n", dev->name); 614 dprintk("mpoa: (%s) mpc_vcc_close:\n", dev->name);
617 in_entry = mpc->in_ops->get_by_vcc(vcc, mpc); 615 in_entry = mpc->in_ops->get_by_vcc(vcc, mpc);
618 if (in_entry) { 616 if (in_entry) {
619 unsigned char *ip __attribute__ ((unused)) =
620 (unsigned char *)&in_entry->ctrl_info.in_dst_ip;
621 dprintk("mpoa: (%s) mpc_vcc_close: ingress SVC closed ip = %u.%u.%u.%u\n", 617 dprintk("mpoa: (%s) mpc_vcc_close: ingress SVC closed ip = %u.%u.%u.%u\n",
622 mpc->dev->name, ip[0], ip[1], ip[2], ip[3]); 618 mpc->dev->name, NIPQUAD(in_entry->ctrl_info.in_dst_ip));
623 in_entry->shortcut = NULL; 619 in_entry->shortcut = NULL;
624 mpc->in_ops->put(in_entry); 620 mpc->in_ops->put(in_entry);
625 } 621 }
@@ -1154,18 +1150,17 @@ static void ingress_purge_rcvd(struct k_message *msg, struct mpoa_client *mpc)
1154{ 1150{
1155 uint32_t dst_ip = msg->content.in_info.in_dst_ip; 1151 uint32_t dst_ip = msg->content.in_info.in_dst_ip;
1156 uint32_t mask = msg->ip_mask; 1152 uint32_t mask = msg->ip_mask;
1157 unsigned char *ip = (unsigned char *)&dst_ip;
1158 in_cache_entry *entry = mpc->in_ops->get_with_mask(dst_ip, mpc, mask); 1153 in_cache_entry *entry = mpc->in_ops->get_with_mask(dst_ip, mpc, mask);
1159 1154
1160 if(entry == NULL){ 1155 if(entry == NULL){
1161 printk("mpoa: (%s) ingress_purge_rcvd: purge for a non-existing entry, ", mpc->dev->name); 1156 printk("mpoa: (%s) ingress_purge_rcvd: purge for a non-existing entry, ", mpc->dev->name);
1162 printk("ip = %u.%u.%u.%u\n", ip[0], ip[1], ip[2], ip[3]); 1157 printk("ip = %u.%u.%u.%u\n", NIPQUAD(dst_ip));
1163 return; 1158 return;
1164 } 1159 }
1165 1160
1166 do { 1161 do {
1167 dprintk("mpoa: (%s) ingress_purge_rcvd: removing an ingress entry, ip = %u.%u.%u.%u\n" , 1162 dprintk("mpoa: (%s) ingress_purge_rcvd: removing an ingress entry, ip = %u.%u.%u.%u\n" ,
1168 mpc->dev->name, ip[0], ip[1], ip[2], ip[3]); 1163 mpc->dev->name, NIPQUAD(dst_ip));
1169 write_lock_bh(&mpc->ingress_lock); 1164 write_lock_bh(&mpc->ingress_lock);
1170 mpc->in_ops->remove_entry(entry, mpc); 1165 mpc->in_ops->remove_entry(entry, mpc);
1171 write_unlock_bh(&mpc->ingress_lock); 1166 write_unlock_bh(&mpc->ingress_lock);
diff --git a/net/atm/mpoa_caches.c b/net/atm/mpoa_caches.c
index 781ed1b9329d..fbf13cdcf46e 100644
--- a/net/atm/mpoa_caches.c
+++ b/net/atm/mpoa_caches.c
@@ -87,7 +87,6 @@ static in_cache_entry *in_cache_get_by_vcc(struct atm_vcc *vcc,
87static in_cache_entry *in_cache_add_entry(uint32_t dst_ip, 87static in_cache_entry *in_cache_add_entry(uint32_t dst_ip,
88 struct mpoa_client *client) 88 struct mpoa_client *client)
89{ 89{
90 unsigned char *ip __attribute__ ((unused)) = (unsigned char *)&dst_ip;
91 in_cache_entry* entry = kmalloc(sizeof(in_cache_entry), GFP_KERNEL); 90 in_cache_entry* entry = kmalloc(sizeof(in_cache_entry), GFP_KERNEL);
92 91
93 if (entry == NULL) { 92 if (entry == NULL) {
@@ -95,7 +94,7 @@ static in_cache_entry *in_cache_add_entry(uint32_t dst_ip,
95 return NULL; 94 return NULL;
96 } 95 }
97 96
98 dprintk("mpoa: mpoa_caches.c: adding an ingress entry, ip = %u.%u.%u.%u\n", ip[0], ip[1], ip[2], ip[3]); 97 dprintk("mpoa: mpoa_caches.c: adding an ingress entry, ip = %u.%u.%u.%u\n", NIPQUAD(dst_ip));
99 memset(entry,0,sizeof(in_cache_entry)); 98 memset(entry,0,sizeof(in_cache_entry));
100 99
101 atomic_set(&entry->use, 1); 100 atomic_set(&entry->use, 1);
@@ -152,10 +151,7 @@ static int cache_hit(in_cache_entry *entry, struct mpoa_client *mpc)
152 151
153 if( entry->count > mpc->parameters.mpc_p1 && 152 if( entry->count > mpc->parameters.mpc_p1 &&
154 entry->entry_state == INGRESS_INVALID){ 153 entry->entry_state == INGRESS_INVALID){
155 unsigned char *ip __attribute__ ((unused)) = 154 dprintk("mpoa: (%s) mpoa_caches.c: threshold exceeded for ip %u.%u.%u.%u, sending MPOA res req\n", mpc->dev->name, NIPQUAD(entry->ctrl_info.in_dst_ip));
156 (unsigned char *)&entry->ctrl_info.in_dst_ip;
157
158 dprintk("mpoa: (%s) mpoa_caches.c: threshold exceeded for ip %u.%u.%u.%u, sending MPOA res req\n", mpc->dev->name, ip[0], ip[1], ip[2], ip[3]);
159 entry->entry_state = INGRESS_RESOLVING; 155 entry->entry_state = INGRESS_RESOLVING;
160 msg.type = SND_MPOA_RES_RQST; 156 msg.type = SND_MPOA_RES_RQST;
161 memcpy(msg.MPS_ctrl, mpc->mps_ctrl_addr, ATM_ESA_LEN ); 157 memcpy(msg.MPS_ctrl, mpc->mps_ctrl_addr, ATM_ESA_LEN );
@@ -187,11 +183,9 @@ static void in_cache_remove_entry(in_cache_entry *entry,
187{ 183{
188 struct atm_vcc *vcc; 184 struct atm_vcc *vcc;
189 struct k_message msg; 185 struct k_message msg;
190 unsigned char *ip;
191 186
192 vcc = entry->shortcut; 187 vcc = entry->shortcut;
193 ip = (unsigned char *)&entry->ctrl_info.in_dst_ip; 188 dprintk("mpoa: mpoa_caches.c: removing an ingress entry, ip = %u.%u.%u.%u\n",NIPQUAD(entry->ctrl_info.in_dst_ip));
194 dprintk("mpoa: mpoa_caches.c: removing an ingress entry, ip = %u.%u.%u.%u\n",ip[0], ip[1], ip[2], ip[3]);
195 189
196 if (entry->prev != NULL) 190 if (entry->prev != NULL)
197 entry->prev->next = entry->next; 191 entry->prev->next = entry->next;
diff --git a/net/bluetooth/af_bluetooth.c b/net/bluetooth/af_bluetooth.c
index 788ea7a2b744..305a099b7477 100644
--- a/net/bluetooth/af_bluetooth.c
+++ b/net/bluetooth/af_bluetooth.c
@@ -276,7 +276,7 @@ int bt_sock_wait_state(struct sock *sk, int state, unsigned long timeo)
276 set_current_state(TASK_INTERRUPTIBLE); 276 set_current_state(TASK_INTERRUPTIBLE);
277 277
278 if (!timeo) { 278 if (!timeo) {
279 err = -EAGAIN; 279 err = -EINPROGRESS;
280 break; 280 break;
281 } 281 }
282 282
diff --git a/net/bluetooth/bnep/core.c b/net/bluetooth/bnep/core.c
index e620061fb50f..2312d050eeed 100644
--- a/net/bluetooth/bnep/core.c
+++ b/net/bluetooth/bnep/core.c
@@ -51,6 +51,7 @@
51#include <asm/unaligned.h> 51#include <asm/unaligned.h>
52 52
53#include <net/bluetooth/bluetooth.h> 53#include <net/bluetooth/bluetooth.h>
54#include <net/bluetooth/hci_core.h>
54#include <net/bluetooth/l2cap.h> 55#include <net/bluetooth/l2cap.h>
55 56
56#include "bnep.h" 57#include "bnep.h"
@@ -515,6 +516,26 @@ static int bnep_session(void *arg)
515 return 0; 516 return 0;
516} 517}
517 518
519static struct device *bnep_get_device(struct bnep_session *session)
520{
521 bdaddr_t *src = &bt_sk(session->sock->sk)->src;
522 bdaddr_t *dst = &bt_sk(session->sock->sk)->dst;
523 struct hci_dev *hdev;
524 struct hci_conn *conn;
525
526 hdev = hci_get_route(dst, src);
527 if (!hdev)
528 return NULL;
529
530 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, dst);
531 if (!conn)
532 return NULL;
533
534 hci_dev_put(hdev);
535
536 return &conn->dev;
537}
538
518int bnep_add_connection(struct bnep_connadd_req *req, struct socket *sock) 539int bnep_add_connection(struct bnep_connadd_req *req, struct socket *sock)
519{ 540{
520 struct net_device *dev; 541 struct net_device *dev;
@@ -534,7 +555,6 @@ int bnep_add_connection(struct bnep_connadd_req *req, struct socket *sock)
534 if (!dev) 555 if (!dev)
535 return -ENOMEM; 556 return -ENOMEM;
536 557
537
538 down_write(&bnep_session_sem); 558 down_write(&bnep_session_sem);
539 559
540 ss = __bnep_get_session(dst); 560 ss = __bnep_get_session(dst);
@@ -551,7 +571,7 @@ int bnep_add_connection(struct bnep_connadd_req *req, struct socket *sock)
551 memcpy(s->eh.h_source, &dst, ETH_ALEN); 571 memcpy(s->eh.h_source, &dst, ETH_ALEN);
552 memcpy(dev->dev_addr, s->eh.h_dest, ETH_ALEN); 572 memcpy(dev->dev_addr, s->eh.h_dest, ETH_ALEN);
553 573
554 s->dev = dev; 574 s->dev = dev;
555 s->sock = sock; 575 s->sock = sock;
556 s->role = req->role; 576 s->role = req->role;
557 s->state = BT_CONNECTED; 577 s->state = BT_CONNECTED;
@@ -568,6 +588,8 @@ int bnep_add_connection(struct bnep_connadd_req *req, struct socket *sock)
568 bnep_set_default_proto_filter(s); 588 bnep_set_default_proto_filter(s);
569#endif 589#endif
570 590
591 SET_NETDEV_DEV(dev, bnep_get_device(s));
592
571 err = register_netdev(dev); 593 err = register_netdev(dev);
572 if (err) { 594 if (err) {
573 goto failed; 595 goto failed;
diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
index 420ed4d7e57e..90e3a285a17e 100644
--- a/net/bluetooth/hci_conn.c
+++ b/net/bluetooth/hci_conn.c
@@ -84,6 +84,20 @@ static void hci_acl_connect(struct hci_conn *conn)
84 hci_send_cmd(hdev, OGF_LINK_CTL, OCF_CREATE_CONN, sizeof(cp), &cp); 84 hci_send_cmd(hdev, OGF_LINK_CTL, OCF_CREATE_CONN, sizeof(cp), &cp);
85} 85}
86 86
87static void hci_acl_connect_cancel(struct hci_conn *conn)
88{
89 struct hci_cp_create_conn_cancel cp;
90
91 BT_DBG("%p", conn);
92
93 if (conn->hdev->hci_ver < 2)
94 return;
95
96 bacpy(&cp.bdaddr, &conn->dst);
97 hci_send_cmd(conn->hdev, OGF_LINK_CTL,
98 OCF_CREATE_CONN_CANCEL, sizeof(cp), &cp);
99}
100
87void hci_acl_disconn(struct hci_conn *conn, __u8 reason) 101void hci_acl_disconn(struct hci_conn *conn, __u8 reason)
88{ 102{
89 struct hci_cp_disconnect cp; 103 struct hci_cp_disconnect cp;
@@ -94,7 +108,8 @@ void hci_acl_disconn(struct hci_conn *conn, __u8 reason)
94 108
95 cp.handle = __cpu_to_le16(conn->handle); 109 cp.handle = __cpu_to_le16(conn->handle);
96 cp.reason = reason; 110 cp.reason = reason;
97 hci_send_cmd(conn->hdev, OGF_LINK_CTL, OCF_DISCONNECT, sizeof(cp), &cp); 111 hci_send_cmd(conn->hdev, OGF_LINK_CTL,
112 OCF_DISCONNECT, sizeof(cp), &cp);
98} 113}
99 114
100void hci_add_sco(struct hci_conn *conn, __u16 handle) 115void hci_add_sco(struct hci_conn *conn, __u16 handle)
@@ -124,12 +139,20 @@ static void hci_conn_timeout(unsigned long arg)
124 return; 139 return;
125 140
126 hci_dev_lock(hdev); 141 hci_dev_lock(hdev);
127 if (conn->state == BT_CONNECTED) 142
143 switch (conn->state) {
144 case BT_CONNECT:
145 hci_acl_connect_cancel(conn);
146 break;
147 case BT_CONNECTED:
128 hci_acl_disconn(conn, 0x13); 148 hci_acl_disconn(conn, 0x13);
129 else 149 break;
150 default:
130 conn->state = BT_CLOSED; 151 conn->state = BT_CLOSED;
152 break;
153 }
154
131 hci_dev_unlock(hdev); 155 hci_dev_unlock(hdev);
132 return;
133} 156}
134 157
135static void hci_conn_idle(unsigned long arg) 158static void hci_conn_idle(unsigned long arg)
@@ -179,6 +202,8 @@ struct hci_conn *hci_conn_add(struct hci_dev *hdev, int type, bdaddr_t *dst)
179 if (hdev->notify) 202 if (hdev->notify)
180 hdev->notify(hdev, HCI_NOTIFY_CONN_ADD); 203 hdev->notify(hdev, HCI_NOTIFY_CONN_ADD);
181 204
205 hci_conn_add_sysfs(conn);
206
182 tasklet_enable(&hdev->tx_task); 207 tasklet_enable(&hdev->tx_task);
183 208
184 return conn; 209 return conn;
@@ -211,6 +236,8 @@ int hci_conn_del(struct hci_conn *conn)
211 236
212 tasklet_disable(&hdev->tx_task); 237 tasklet_disable(&hdev->tx_task);
213 238
239 hci_conn_del_sysfs(conn);
240
214 hci_conn_hash_del(hdev, conn); 241 hci_conn_hash_del(hdev, conn);
215 if (hdev->notify) 242 if (hdev->notify)
216 hdev->notify(hdev, HCI_NOTIFY_CONN_DEL); 243 hdev->notify(hdev, HCI_NOTIFY_CONN_DEL);
@@ -221,7 +248,9 @@ int hci_conn_del(struct hci_conn *conn)
221 248
222 hci_dev_put(hdev); 249 hci_dev_put(hdev);
223 250
224 kfree(conn); 251 /* will free via device release */
252 put_device(&conn->dev);
253
225 return 0; 254 return 0;
226} 255}
227 256
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 5ed474277903..338ae977a31b 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -206,6 +206,9 @@ static void hci_init_req(struct hci_dev *hdev, unsigned long opt)
206 /* Read Local Supported Features */ 206 /* Read Local Supported Features */
207 hci_send_cmd(hdev, OGF_INFO_PARAM, OCF_READ_LOCAL_FEATURES, 0, NULL); 207 hci_send_cmd(hdev, OGF_INFO_PARAM, OCF_READ_LOCAL_FEATURES, 0, NULL);
208 208
209 /* Read Local Version */
210 hci_send_cmd(hdev, OGF_INFO_PARAM, OCF_READ_LOCAL_VERSION, 0, NULL);
211
209 /* Read Buffer Size (ACL mtu, max pkt, etc.) */ 212 /* Read Buffer Size (ACL mtu, max pkt, etc.) */
210 hci_send_cmd(hdev, OGF_INFO_PARAM, OCF_READ_BUFFER_SIZE, 0, NULL); 213 hci_send_cmd(hdev, OGF_INFO_PARAM, OCF_READ_BUFFER_SIZE, 0, NULL);
211 214
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 3896dabab11d..d43d0c890975 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -62,6 +62,7 @@ static void hci_cc_link_ctl(struct hci_dev *hdev, __u16 ocf, struct sk_buff *skb
62 62
63 switch (ocf) { 63 switch (ocf) {
64 case OCF_INQUIRY_CANCEL: 64 case OCF_INQUIRY_CANCEL:
65 case OCF_EXIT_PERIODIC_INQ:
65 status = *((__u8 *) skb->data); 66 status = *((__u8 *) skb->data);
66 67
67 if (status) { 68 if (status) {
@@ -297,6 +298,7 @@ static void hci_cc_host_ctl(struct hci_dev *hdev, __u16 ocf, struct sk_buff *skb
297/* Command Complete OGF INFO_PARAM */ 298/* Command Complete OGF INFO_PARAM */
298static void hci_cc_info_param(struct hci_dev *hdev, __u16 ocf, struct sk_buff *skb) 299static void hci_cc_info_param(struct hci_dev *hdev, __u16 ocf, struct sk_buff *skb)
299{ 300{
301 struct hci_rp_read_loc_version *lv;
300 struct hci_rp_read_local_features *lf; 302 struct hci_rp_read_local_features *lf;
301 struct hci_rp_read_buffer_size *bs; 303 struct hci_rp_read_buffer_size *bs;
302 struct hci_rp_read_bd_addr *ba; 304 struct hci_rp_read_bd_addr *ba;
@@ -304,6 +306,23 @@ static void hci_cc_info_param(struct hci_dev *hdev, __u16 ocf, struct sk_buff *s
304 BT_DBG("%s ocf 0x%x", hdev->name, ocf); 306 BT_DBG("%s ocf 0x%x", hdev->name, ocf);
305 307
306 switch (ocf) { 308 switch (ocf) {
309 case OCF_READ_LOCAL_VERSION:
310 lv = (struct hci_rp_read_loc_version *) skb->data;
311
312 if (lv->status) {
313 BT_DBG("%s READ_LOCAL_VERSION failed %d", hdev->name, lf->status);
314 break;
315 }
316
317 hdev->hci_ver = lv->hci_ver;
318 hdev->hci_rev = btohs(lv->hci_rev);
319 hdev->manufacturer = btohs(lv->manufacturer);
320
321 BT_DBG("%s: manufacturer %d hci_ver %d hci_rev %d", hdev->name,
322 hdev->manufacturer, hdev->hci_ver, hdev->hci_rev);
323
324 break;
325
307 case OCF_READ_LOCAL_FEATURES: 326 case OCF_READ_LOCAL_FEATURES:
308 lf = (struct hci_rp_read_local_features *) skb->data; 327 lf = (struct hci_rp_read_local_features *) skb->data;
309 328
@@ -328,7 +347,8 @@ static void hci_cc_info_param(struct hci_dev *hdev, __u16 ocf, struct sk_buff *s
328 if (hdev->features[1] & LMP_HV3) 347 if (hdev->features[1] & LMP_HV3)
329 hdev->pkt_type |= (HCI_HV3); 348 hdev->pkt_type |= (HCI_HV3);
330 349
331 BT_DBG("%s: features 0x%x 0x%x 0x%x", hdev->name, lf->features[0], lf->features[1], lf->features[2]); 350 BT_DBG("%s: features 0x%x 0x%x 0x%x", hdev->name,
351 lf->features[0], lf->features[1], lf->features[2]);
332 352
333 break; 353 break;
334 354
@@ -757,6 +777,10 @@ static inline void hci_conn_complete_evt(struct hci_dev *hdev, struct sk_buff *s
757 777
758 hci_send_cmd(hdev, OGF_LINK_CTL, 778 hci_send_cmd(hdev, OGF_LINK_CTL,
759 OCF_CHANGE_CONN_PTYPE, sizeof(cp), &cp); 779 OCF_CHANGE_CONN_PTYPE, sizeof(cp), &cp);
780 } else {
781 /* Update disconnect timer */
782 hci_conn_hold(conn);
783 hci_conn_put(conn);
760 } 784 }
761 } else 785 } else
762 conn->state = BT_CLOSED; 786 conn->state = BT_CLOSED;
diff --git a/net/bluetooth/hci_sysfs.c b/net/bluetooth/hci_sysfs.c
index 3987d167f04e..989b22d9042e 100644
--- a/net/bluetooth/hci_sysfs.c
+++ b/net/bluetooth/hci_sysfs.c
@@ -13,16 +13,32 @@
13#define BT_DBG(D...) 13#define BT_DBG(D...)
14#endif 14#endif
15 15
16static ssize_t show_name(struct device *dev, struct device_attribute *attr, char *buf) 16static inline char *typetostr(int type)
17{ 17{
18 struct hci_dev *hdev = dev_get_drvdata(dev); 18 switch (type) {
19 return sprintf(buf, "%s\n", hdev->name); 19 case HCI_VIRTUAL:
20 return "VIRTUAL";
21 case HCI_USB:
22 return "USB";
23 case HCI_PCCARD:
24 return "PCCARD";
25 case HCI_UART:
26 return "UART";
27 case HCI_RS232:
28 return "RS232";
29 case HCI_PCI:
30 return "PCI";
31 case HCI_SDIO:
32 return "SDIO";
33 default:
34 return "UNKNOWN";
35 }
20} 36}
21 37
22static ssize_t show_type(struct device *dev, struct device_attribute *attr, char *buf) 38static ssize_t show_type(struct device *dev, struct device_attribute *attr, char *buf)
23{ 39{
24 struct hci_dev *hdev = dev_get_drvdata(dev); 40 struct hci_dev *hdev = dev_get_drvdata(dev);
25 return sprintf(buf, "%d\n", hdev->type); 41 return sprintf(buf, "%s\n", typetostr(hdev->type));
26} 42}
27 43
28static ssize_t show_address(struct device *dev, struct device_attribute *attr, char *buf) 44static ssize_t show_address(struct device *dev, struct device_attribute *attr, char *buf)
@@ -33,10 +49,22 @@ static ssize_t show_address(struct device *dev, struct device_attribute *attr, c
33 return sprintf(buf, "%s\n", batostr(&bdaddr)); 49 return sprintf(buf, "%s\n", batostr(&bdaddr));
34} 50}
35 51
36static ssize_t show_flags(struct device *dev, struct device_attribute *attr, char *buf) 52static ssize_t show_manufacturer(struct device *dev, struct device_attribute *attr, char *buf)
53{
54 struct hci_dev *hdev = dev_get_drvdata(dev);
55 return sprintf(buf, "%d\n", hdev->manufacturer);
56}
57
58static ssize_t show_hci_version(struct device *dev, struct device_attribute *attr, char *buf)
37{ 59{
38 struct hci_dev *hdev = dev_get_drvdata(dev); 60 struct hci_dev *hdev = dev_get_drvdata(dev);
39 return sprintf(buf, "0x%lx\n", hdev->flags); 61 return sprintf(buf, "%d\n", hdev->hci_ver);
62}
63
64static ssize_t show_hci_revision(struct device *dev, struct device_attribute *attr, char *buf)
65{
66 struct hci_dev *hdev = dev_get_drvdata(dev);
67 return sprintf(buf, "%d\n", hdev->hci_rev);
40} 68}
41 69
42static ssize_t show_inquiry_cache(struct device *dev, struct device_attribute *attr, char *buf) 70static ssize_t show_inquiry_cache(struct device *dev, struct device_attribute *attr, char *buf)
@@ -141,10 +169,11 @@ static ssize_t store_sniff_min_interval(struct device *dev, struct device_attrib
141 return count; 169 return count;
142} 170}
143 171
144static DEVICE_ATTR(name, S_IRUGO, show_name, NULL);
145static DEVICE_ATTR(type, S_IRUGO, show_type, NULL); 172static DEVICE_ATTR(type, S_IRUGO, show_type, NULL);
146static DEVICE_ATTR(address, S_IRUGO, show_address, NULL); 173static DEVICE_ATTR(address, S_IRUGO, show_address, NULL);
147static DEVICE_ATTR(flags, S_IRUGO, show_flags, NULL); 174static DEVICE_ATTR(manufacturer, S_IRUGO, show_manufacturer, NULL);
175static DEVICE_ATTR(hci_version, S_IRUGO, show_hci_version, NULL);
176static DEVICE_ATTR(hci_revision, S_IRUGO, show_hci_revision, NULL);
148static DEVICE_ATTR(inquiry_cache, S_IRUGO, show_inquiry_cache, NULL); 177static DEVICE_ATTR(inquiry_cache, S_IRUGO, show_inquiry_cache, NULL);
149 178
150static DEVICE_ATTR(idle_timeout, S_IRUGO | S_IWUSR, 179static DEVICE_ATTR(idle_timeout, S_IRUGO | S_IWUSR,
@@ -155,10 +184,11 @@ static DEVICE_ATTR(sniff_min_interval, S_IRUGO | S_IWUSR,
155 show_sniff_min_interval, store_sniff_min_interval); 184 show_sniff_min_interval, store_sniff_min_interval);
156 185
157static struct device_attribute *bt_attrs[] = { 186static struct device_attribute *bt_attrs[] = {
158 &dev_attr_name,
159 &dev_attr_type, 187 &dev_attr_type,
160 &dev_attr_address, 188 &dev_attr_address,
161 &dev_attr_flags, 189 &dev_attr_manufacturer,
190 &dev_attr_hci_version,
191 &dev_attr_hci_revision,
162 &dev_attr_inquiry_cache, 192 &dev_attr_inquiry_cache,
163 &dev_attr_idle_timeout, 193 &dev_attr_idle_timeout,
164 &dev_attr_sniff_max_interval, 194 &dev_attr_sniff_max_interval,
@@ -166,6 +196,32 @@ static struct device_attribute *bt_attrs[] = {
166 NULL 196 NULL
167}; 197};
168 198
199static ssize_t show_conn_type(struct device *dev, struct device_attribute *attr, char *buf)
200{
201 struct hci_conn *conn = dev_get_drvdata(dev);
202 return sprintf(buf, "%s\n", conn->type == ACL_LINK ? "ACL" : "SCO");
203}
204
205static ssize_t show_conn_address(struct device *dev, struct device_attribute *attr, char *buf)
206{
207 struct hci_conn *conn = dev_get_drvdata(dev);
208 bdaddr_t bdaddr;
209 baswap(&bdaddr, &conn->dst);
210 return sprintf(buf, "%s\n", batostr(&bdaddr));
211}
212
213#define CONN_ATTR(_name,_mode,_show,_store) \
214struct device_attribute conn_attr_##_name = __ATTR(_name,_mode,_show,_store)
215
216static CONN_ATTR(type, S_IRUGO, show_conn_type, NULL);
217static CONN_ATTR(address, S_IRUGO, show_conn_address, NULL);
218
219static struct device_attribute *conn_attrs[] = {
220 &conn_attr_type,
221 &conn_attr_address,
222 NULL
223};
224
169struct class *bt_class = NULL; 225struct class *bt_class = NULL;
170EXPORT_SYMBOL_GPL(bt_class); 226EXPORT_SYMBOL_GPL(bt_class);
171 227
@@ -177,8 +233,57 @@ static struct platform_device *bt_platform;
177 233
178static void bt_release(struct device *dev) 234static void bt_release(struct device *dev)
179{ 235{
180 struct hci_dev *hdev = dev_get_drvdata(dev); 236 void *data = dev_get_drvdata(dev);
181 kfree(hdev); 237 kfree(data);
238}
239
240static void add_conn(void *data)
241{
242 struct hci_conn *conn = data;
243 int i;
244
245 device_register(&conn->dev);
246
247 for (i = 0; conn_attrs[i]; i++)
248 device_create_file(&conn->dev, conn_attrs[i]);
249}
250
251void hci_conn_add_sysfs(struct hci_conn *conn)
252{
253 struct hci_dev *hdev = conn->hdev;
254 bdaddr_t *ba = &conn->dst;
255
256 BT_DBG("conn %p", conn);
257
258 conn->dev.parent = &hdev->dev;
259 conn->dev.release = bt_release;
260
261 snprintf(conn->dev.bus_id, BUS_ID_SIZE,
262 "%s%2.2X%2.2X%2.2X%2.2X%2.2X%2.2X",
263 conn->type == ACL_LINK ? "acl" : "sco",
264 ba->b[5], ba->b[4], ba->b[3],
265 ba->b[2], ba->b[1], ba->b[0]);
266
267 dev_set_drvdata(&conn->dev, conn);
268
269 INIT_WORK(&conn->work, add_conn, (void *) conn);
270
271 schedule_work(&conn->work);
272}
273
274static void del_conn(void *data)
275{
276 struct hci_conn *conn = data;
277 device_del(&conn->dev);
278}
279
280void hci_conn_del_sysfs(struct hci_conn *conn)
281{
282 BT_DBG("conn %p", conn);
283
284 INIT_WORK(&conn->work, del_conn, (void *) conn);
285
286 schedule_work(&conn->work);
182} 287}
183 288
184int hci_register_sysfs(struct hci_dev *hdev) 289int hci_register_sysfs(struct hci_dev *hdev)
@@ -214,11 +319,9 @@ int hci_register_sysfs(struct hci_dev *hdev)
214 319
215void hci_unregister_sysfs(struct hci_dev *hdev) 320void hci_unregister_sysfs(struct hci_dev *hdev)
216{ 321{
217 struct device *dev = &hdev->dev;
218
219 BT_DBG("%p name %s type %d", hdev, hdev->name, hdev->type); 322 BT_DBG("%p name %s type %d", hdev, hdev->name, hdev->type);
220 323
221 device_del(dev); 324 device_del(&hdev->dev);
222} 325}
223 326
224int __init bt_sysfs_init(void) 327int __init bt_sysfs_init(void)
@@ -245,7 +348,7 @@ int __init bt_sysfs_init(void)
245 return 0; 348 return 0;
246} 349}
247 350
248void __exit bt_sysfs_cleanup(void) 351void bt_sysfs_cleanup(void)
249{ 352{
250 class_destroy(bt_class); 353 class_destroy(bt_class);
251 354
diff --git a/net/bluetooth/hidp/core.c b/net/bluetooth/hidp/core.c
index c6e3a2c27c6e..03b5dadb4951 100644
--- a/net/bluetooth/hidp/core.c
+++ b/net/bluetooth/hidp/core.c
@@ -40,6 +40,7 @@
40#include <linux/input.h> 40#include <linux/input.h>
41 41
42#include <net/bluetooth/bluetooth.h> 42#include <net/bluetooth/bluetooth.h>
43#include <net/bluetooth/hci_core.h>
43#include <net/bluetooth/l2cap.h> 44#include <net/bluetooth/l2cap.h>
44 45
45#include "hidp.h" 46#include "hidp.h"
@@ -528,6 +529,26 @@ static int hidp_session(void *arg)
528 return 0; 529 return 0;
529} 530}
530 531
532static struct device *hidp_get_device(struct hidp_session *session)
533{
534 bdaddr_t *src = &bt_sk(session->ctrl_sock->sk)->src;
535 bdaddr_t *dst = &bt_sk(session->ctrl_sock->sk)->dst;
536 struct hci_dev *hdev;
537 struct hci_conn *conn;
538
539 hdev = hci_get_route(dst, src);
540 if (!hdev)
541 return NULL;
542
543 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, dst);
544 if (!conn)
545 return NULL;
546
547 hci_dev_put(hdev);
548
549 return &conn->dev;
550}
551
531static inline void hidp_setup_input(struct hidp_session *session, struct hidp_connadd_req *req) 552static inline void hidp_setup_input(struct hidp_session *session, struct hidp_connadd_req *req)
532{ 553{
533 struct input_dev *input = session->input; 554 struct input_dev *input = session->input;
@@ -566,6 +587,8 @@ static inline void hidp_setup_input(struct hidp_session *session, struct hidp_co
566 input->relbit[0] |= BIT(REL_WHEEL); 587 input->relbit[0] |= BIT(REL_WHEEL);
567 } 588 }
568 589
590 input->cdev.dev = hidp_get_device(session);
591
569 input->event = hidp_input_event; 592 input->event = hidp_input_event;
570 593
571 input_register_device(input); 594 input_register_device(input);
diff --git a/net/bluetooth/rfcomm/core.c b/net/bluetooth/rfcomm/core.c
index 332dd8f436ea..468df3b953f6 100644
--- a/net/bluetooth/rfcomm/core.c
+++ b/net/bluetooth/rfcomm/core.c
@@ -644,7 +644,7 @@ static struct rfcomm_session *rfcomm_session_create(bdaddr_t *src, bdaddr_t *dst
644 addr.l2_family = AF_BLUETOOTH; 644 addr.l2_family = AF_BLUETOOTH;
645 addr.l2_psm = htobs(RFCOMM_PSM); 645 addr.l2_psm = htobs(RFCOMM_PSM);
646 *err = sock->ops->connect(sock, (struct sockaddr *) &addr, sizeof(addr), O_NONBLOCK); 646 *err = sock->ops->connect(sock, (struct sockaddr *) &addr, sizeof(addr), O_NONBLOCK);
647 if (*err == 0 || *err == -EAGAIN) 647 if (*err == 0 || *err == -EINPROGRESS)
648 return s; 648 return s;
649 649
650 rfcomm_session_del(s); 650 rfcomm_session_del(s);
diff --git a/net/bluetooth/rfcomm/tty.c b/net/bluetooth/rfcomm/tty.c
index bd8d671a0ba6..26f322737db0 100644
--- a/net/bluetooth/rfcomm/tty.c
+++ b/net/bluetooth/rfcomm/tty.c
@@ -38,6 +38,7 @@
38#include <linux/skbuff.h> 38#include <linux/skbuff.h>
39 39
40#include <net/bluetooth/bluetooth.h> 40#include <net/bluetooth/bluetooth.h>
41#include <net/bluetooth/hci_core.h>
41#include <net/bluetooth/rfcomm.h> 42#include <net/bluetooth/rfcomm.h>
42 43
43#ifndef CONFIG_BT_RFCOMM_DEBUG 44#ifndef CONFIG_BT_RFCOMM_DEBUG
@@ -161,6 +162,24 @@ static inline struct rfcomm_dev *rfcomm_dev_get(int id)
161 return dev; 162 return dev;
162} 163}
163 164
165static struct device *rfcomm_get_device(struct rfcomm_dev *dev)
166{
167 struct hci_dev *hdev;
168 struct hci_conn *conn;
169
170 hdev = hci_get_route(&dev->dst, &dev->src);
171 if (!hdev)
172 return NULL;
173
174 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &dev->dst);
175 if (!conn)
176 return NULL;
177
178 hci_dev_put(hdev);
179
180 return &conn->dev;
181}
182
164static int rfcomm_dev_add(struct rfcomm_dev_req *req, struct rfcomm_dlc *dlc) 183static int rfcomm_dev_add(struct rfcomm_dev_req *req, struct rfcomm_dlc *dlc)
165{ 184{
166 struct rfcomm_dev *dev; 185 struct rfcomm_dev *dev;
@@ -244,7 +263,7 @@ out:
244 return err; 263 return err;
245 } 264 }
246 265
247 tty_register_device(rfcomm_tty_driver, dev->id, NULL); 266 tty_register_device(rfcomm_tty_driver, dev->id, rfcomm_get_device(dev));
248 267
249 return dev->id; 268 return dev->id;
250} 269}
diff --git a/net/bridge/netfilter/ebt_arpreply.c b/net/bridge/netfilter/ebt_arpreply.c
index d19fc4b328dc..0aa7b9910a86 100644
--- a/net/bridge/netfilter/ebt_arpreply.c
+++ b/net/bridge/netfilter/ebt_arpreply.c
@@ -20,7 +20,7 @@ static int ebt_target_reply(struct sk_buff **pskb, unsigned int hooknr,
20 const void *data, unsigned int datalen) 20 const void *data, unsigned int datalen)
21{ 21{
22 struct ebt_arpreply_info *info = (struct ebt_arpreply_info *)data; 22 struct ebt_arpreply_info *info = (struct ebt_arpreply_info *)data;
23 u32 _sip, *siptr, _dip, *diptr; 23 __be32 _sip, *siptr, _dip, *diptr;
24 struct arphdr _ah, *ap; 24 struct arphdr _ah, *ap;
25 unsigned char _sha[ETH_ALEN], *shp; 25 unsigned char _sha[ETH_ALEN], *shp;
26 struct sk_buff *skb = *pskb; 26 struct sk_buff *skb = *pskb;
diff --git a/net/core/dev.c b/net/core/dev.c
index 14de297d024d..4d891beab138 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -1480,14 +1480,16 @@ gso:
1480 if (q->enqueue) { 1480 if (q->enqueue) {
1481 /* Grab device queue */ 1481 /* Grab device queue */
1482 spin_lock(&dev->queue_lock); 1482 spin_lock(&dev->queue_lock);
1483 q = dev->qdisc;
1484 if (q->enqueue) {
1485 rc = q->enqueue(skb, q);
1486 qdisc_run(dev);
1487 spin_unlock(&dev->queue_lock);
1483 1488
1484 rc = q->enqueue(skb, q); 1489 rc = rc == NET_XMIT_BYPASS ? NET_XMIT_SUCCESS : rc;
1485 1490 goto out;
1486 qdisc_run(dev); 1491 }
1487
1488 spin_unlock(&dev->queue_lock); 1492 spin_unlock(&dev->queue_lock);
1489 rc = rc == NET_XMIT_BYPASS ? NET_XMIT_SUCCESS : rc;
1490 goto out;
1491 } 1493 }
1492 1494
1493 /* The device has no queue. Common case for software devices: 1495 /* The device has no queue. Common case for software devices:
diff --git a/net/core/ethtool.c b/net/core/ethtool.c
index e0ca04f38cef..87dc556fd9d6 100644
--- a/net/core/ethtool.c
+++ b/net/core/ethtool.c
@@ -806,13 +806,6 @@ int dev_ethtool(struct ifreq *ifr)
806 int rc; 806 int rc;
807 unsigned long old_features; 807 unsigned long old_features;
808 808
809 /*
810 * XXX: This can be pushed down into the ethtool_* handlers that
811 * need it. Keep existing behaviour for the moment.
812 */
813 if (!capable(CAP_NET_ADMIN))
814 return -EPERM;
815
816 if (!dev || !netif_device_present(dev)) 809 if (!dev || !netif_device_present(dev))
817 return -ENODEV; 810 return -ENODEV;
818 811
@@ -822,6 +815,27 @@ int dev_ethtool(struct ifreq *ifr)
822 if (copy_from_user(&ethcmd, useraddr, sizeof (ethcmd))) 815 if (copy_from_user(&ethcmd, useraddr, sizeof (ethcmd)))
823 return -EFAULT; 816 return -EFAULT;
824 817
818 /* Allow some commands to be done by anyone */
819 switch(ethcmd) {
820 case ETHTOOL_GDRVINFO:
821 case ETHTOOL_GMSGLVL:
822 case ETHTOOL_GCOALESCE:
823 case ETHTOOL_GRINGPARAM:
824 case ETHTOOL_GPAUSEPARAM:
825 case ETHTOOL_GRXCSUM:
826 case ETHTOOL_GTXCSUM:
827 case ETHTOOL_GSG:
828 case ETHTOOL_GSTRINGS:
829 case ETHTOOL_GTSO:
830 case ETHTOOL_GPERMADDR:
831 case ETHTOOL_GUFO:
832 case ETHTOOL_GGSO:
833 break;
834 default:
835 if (!capable(CAP_NET_ADMIN))
836 return -EPERM;
837 }
838
825 if(dev->ethtool_ops->begin) 839 if(dev->ethtool_ops->begin)
826 if ((rc = dev->ethtool_ops->begin(dev)) < 0) 840 if ((rc = dev->ethtool_ops->begin(dev)) < 0)
827 return rc; 841 return rc;
@@ -947,6 +961,10 @@ int dev_ethtool(struct ifreq *ifr)
947 return rc; 961 return rc;
948 962
949 ioctl: 963 ioctl:
964 /* Keep existing behaviour for the moment. */
965 if (!capable(CAP_NET_ADMIN))
966 return -EPERM;
967
950 if (dev->do_ioctl) 968 if (dev->do_ioctl)
951 return dev->do_ioctl(dev, ifr, SIOCETHTOOL); 969 return dev->do_ioctl(dev, ifr, SIOCETHTOOL);
952 return -EOPNOTSUPP; 970 return -EOPNOTSUPP;
diff --git a/net/core/neighbour.c b/net/core/neighbour.c
index b6c69e1463e8..8ce8c471d868 100644
--- a/net/core/neighbour.c
+++ b/net/core/neighbour.c
@@ -1079,7 +1079,7 @@ struct neighbour *neigh_event_ns(struct neigh_table *tbl,
1079} 1079}
1080 1080
1081static void neigh_hh_init(struct neighbour *n, struct dst_entry *dst, 1081static void neigh_hh_init(struct neighbour *n, struct dst_entry *dst,
1082 u16 protocol) 1082 __be16 protocol)
1083{ 1083{
1084 struct hh_cache *hh; 1084 struct hh_cache *hh;
1085 struct net_device *dev = dst->dev; 1085 struct net_device *dev = dst->dev;
diff --git a/net/core/pktgen.c b/net/core/pktgen.c
index 72145d4a2600..dd023fd28304 100644
--- a/net/core/pktgen.c
+++ b/net/core/pktgen.c
@@ -109,6 +109,8 @@
109 * 109 *
110 * MPLS support by Steven Whitehouse <steve@chygwyn.com> 110 * MPLS support by Steven Whitehouse <steve@chygwyn.com>
111 * 111 *
112 * 802.1Q/Q-in-Q support by Francesco Fondelli (FF) <francesco.fondelli@gmail.com>
113 *
112 */ 114 */
113#include <linux/sys.h> 115#include <linux/sys.h>
114#include <linux/types.h> 116#include <linux/types.h>
@@ -137,6 +139,7 @@
137#include <linux/inetdevice.h> 139#include <linux/inetdevice.h>
138#include <linux/rtnetlink.h> 140#include <linux/rtnetlink.h>
139#include <linux/if_arp.h> 141#include <linux/if_arp.h>
142#include <linux/if_vlan.h>
140#include <linux/in.h> 143#include <linux/in.h>
141#include <linux/ip.h> 144#include <linux/ip.h>
142#include <linux/ipv6.h> 145#include <linux/ipv6.h>
@@ -157,7 +160,7 @@
157#include <asm/div64.h> /* do_div */ 160#include <asm/div64.h> /* do_div */
158#include <asm/timex.h> 161#include <asm/timex.h>
159 162
160#define VERSION "pktgen v2.67: Packet Generator for packet performance testing.\n" 163#define VERSION "pktgen v2.68: Packet Generator for packet performance testing.\n"
161 164
162/* #define PG_DEBUG(a) a */ 165/* #define PG_DEBUG(a) a */
163#define PG_DEBUG(a) 166#define PG_DEBUG(a)
@@ -178,6 +181,8 @@
178#define F_TXSIZE_RND (1<<6) /* Transmit size is random */ 181#define F_TXSIZE_RND (1<<6) /* Transmit size is random */
179#define F_IPV6 (1<<7) /* Interface in IPV6 Mode */ 182#define F_IPV6 (1<<7) /* Interface in IPV6 Mode */
180#define F_MPLS_RND (1<<8) /* Random MPLS labels */ 183#define F_MPLS_RND (1<<8) /* Random MPLS labels */
184#define F_VID_RND (1<<9) /* Random VLAN ID */
185#define F_SVID_RND (1<<10) /* Random SVLAN ID */
181 186
182/* Thread control flag bits */ 187/* Thread control flag bits */
183#define T_TERMINATE (1<<0) 188#define T_TERMINATE (1<<0)
@@ -198,6 +203,9 @@ static struct proc_dir_entry *pg_proc_dir = NULL;
198 203
199#define MAX_CFLOWS 65536 204#define MAX_CFLOWS 65536
200 205
206#define VLAN_TAG_SIZE(x) ((x)->vlan_id == 0xffff ? 0 : 4)
207#define SVLAN_TAG_SIZE(x) ((x)->svlan_id == 0xffff ? 0 : 4)
208
201struct flow_state { 209struct flow_state {
202 __u32 cur_daddr; 210 __u32 cur_daddr;
203 int count; 211 int count;
@@ -284,10 +292,23 @@ struct pktgen_dev {
284 __u16 udp_dst_min; /* inclusive, dest UDP port */ 292 __u16 udp_dst_min; /* inclusive, dest UDP port */
285 __u16 udp_dst_max; /* exclusive, dest UDP port */ 293 __u16 udp_dst_max; /* exclusive, dest UDP port */
286 294
295 /* DSCP + ECN */
296 __u8 tos; /* six most significant bits of (former) IPv4 TOS are for dscp codepoint */
297 __u8 traffic_class; /* ditto for the (former) Traffic Class in IPv6 (see RFC 3260, sec. 4) */
298
287 /* MPLS */ 299 /* MPLS */
288 unsigned nr_labels; /* Depth of stack, 0 = no MPLS */ 300 unsigned nr_labels; /* Depth of stack, 0 = no MPLS */
289 __be32 labels[MAX_MPLS_LABELS]; 301 __be32 labels[MAX_MPLS_LABELS];
290 302
303 /* VLAN/SVLAN (802.1Q/Q-in-Q) */
304 __u8 vlan_p;
305 __u8 vlan_cfi;
306 __u16 vlan_id; /* 0xffff means no vlan tag */
307
308 __u8 svlan_p;
309 __u8 svlan_cfi;
310 __u16 svlan_id; /* 0xffff means no svlan tag */
311
291 __u32 src_mac_count; /* How many MACs to iterate through */ 312 __u32 src_mac_count; /* How many MACs to iterate through */
292 __u32 dst_mac_count; /* How many MACs to iterate through */ 313 __u32 dst_mac_count; /* How many MACs to iterate through */
293 314
@@ -644,6 +665,24 @@ static int pktgen_if_show(struct seq_file *seq, void *v)
644 i == pkt_dev->nr_labels-1 ? "\n" : ", "); 665 i == pkt_dev->nr_labels-1 ? "\n" : ", ");
645 } 666 }
646 667
668 if (pkt_dev->vlan_id != 0xffff) {
669 seq_printf(seq, " vlan_id: %u vlan_p: %u vlan_cfi: %u\n",
670 pkt_dev->vlan_id, pkt_dev->vlan_p, pkt_dev->vlan_cfi);
671 }
672
673 if (pkt_dev->svlan_id != 0xffff) {
674 seq_printf(seq, " svlan_id: %u vlan_p: %u vlan_cfi: %u\n",
675 pkt_dev->svlan_id, pkt_dev->svlan_p, pkt_dev->svlan_cfi);
676 }
677
678 if (pkt_dev->tos) {
679 seq_printf(seq, " tos: 0x%02x\n", pkt_dev->tos);
680 }
681
682 if (pkt_dev->traffic_class) {
683 seq_printf(seq, " traffic_class: 0x%02x\n", pkt_dev->traffic_class);
684 }
685
647 seq_printf(seq, " Flags: "); 686 seq_printf(seq, " Flags: ");
648 687
649 if (pkt_dev->flags & F_IPV6) 688 if (pkt_dev->flags & F_IPV6)
@@ -673,6 +712,12 @@ static int pktgen_if_show(struct seq_file *seq, void *v)
673 if (pkt_dev->flags & F_MACDST_RND) 712 if (pkt_dev->flags & F_MACDST_RND)
674 seq_printf(seq, "MACDST_RND "); 713 seq_printf(seq, "MACDST_RND ");
675 714
715 if (pkt_dev->flags & F_VID_RND)
716 seq_printf(seq, "VID_RND ");
717
718 if (pkt_dev->flags & F_SVID_RND)
719 seq_printf(seq, "SVID_RND ");
720
676 seq_puts(seq, "\n"); 721 seq_puts(seq, "\n");
677 722
678 sa = pkt_dev->started_at; 723 sa = pkt_dev->started_at;
@@ -715,12 +760,12 @@ static int pktgen_if_show(struct seq_file *seq, void *v)
715} 760}
716 761
717 762
718static int hex32_arg(const char __user *user_buffer, __u32 *num) 763static int hex32_arg(const char __user *user_buffer, unsigned long maxlen, __u32 *num)
719{ 764{
720 int i = 0; 765 int i = 0;
721 *num = 0; 766 *num = 0;
722 767
723 for(; i < 8; i++) { 768 for(; i < maxlen; i++) {
724 char c; 769 char c;
725 *num <<= 4; 770 *num <<= 4;
726 if (get_user(c, &user_buffer[i])) 771 if (get_user(c, &user_buffer[i]))
@@ -815,7 +860,7 @@ static ssize_t get_labels(const char __user *buffer, struct pktgen_dev *pkt_dev)
815 pkt_dev->nr_labels = 0; 860 pkt_dev->nr_labels = 0;
816 do { 861 do {
817 __u32 tmp; 862 __u32 tmp;
818 len = hex32_arg(&buffer[i], &tmp); 863 len = hex32_arg(&buffer[i], 8, &tmp);
819 if (len <= 0) 864 if (len <= 0)
820 return len; 865 return len;
821 pkt_dev->labels[n] = htonl(tmp); 866 pkt_dev->labels[n] = htonl(tmp);
@@ -1140,11 +1185,27 @@ static ssize_t pktgen_if_write(struct file *file,
1140 else if (strcmp(f, "!MPLS_RND") == 0) 1185 else if (strcmp(f, "!MPLS_RND") == 0)
1141 pkt_dev->flags &= ~F_MPLS_RND; 1186 pkt_dev->flags &= ~F_MPLS_RND;
1142 1187
1188 else if (strcmp(f, "VID_RND") == 0)
1189 pkt_dev->flags |= F_VID_RND;
1190
1191 else if (strcmp(f, "!VID_RND") == 0)
1192 pkt_dev->flags &= ~F_VID_RND;
1193
1194 else if (strcmp(f, "SVID_RND") == 0)
1195 pkt_dev->flags |= F_SVID_RND;
1196
1197 else if (strcmp(f, "!SVID_RND") == 0)
1198 pkt_dev->flags &= ~F_SVID_RND;
1199
1200 else if (strcmp(f, "!IPV6") == 0)
1201 pkt_dev->flags &= ~F_IPV6;
1202
1143 else { 1203 else {
1144 sprintf(pg_result, 1204 sprintf(pg_result,
1145 "Flag -:%s:- unknown\nAvailable flags, (prepend ! to un-set flag):\n%s", 1205 "Flag -:%s:- unknown\nAvailable flags, (prepend ! to un-set flag):\n%s",
1146 f, 1206 f,
1147 "IPSRC_RND, IPDST_RND, TXSIZE_RND, UDPSRC_RND, UDPDST_RND, MACSRC_RND, MACDST_RND\n"); 1207 "IPSRC_RND, IPDST_RND, UDPSRC_RND, UDPDST_RND, "
1208 "MACSRC_RND, MACDST_RND, TXSIZE_RND, IPV6, MPLS_RND, VID_RND, SVID_RND\n");
1148 return count; 1209 return count;
1149 } 1210 }
1150 sprintf(pg_result, "OK: flags=0x%x", pkt_dev->flags); 1211 sprintf(pg_result, "OK: flags=0x%x", pkt_dev->flags);
@@ -1445,6 +1506,160 @@ static ssize_t pktgen_if_write(struct file *file,
1445 offset += sprintf(pg_result + offset, 1506 offset += sprintf(pg_result + offset,
1446 "%08x%s", ntohl(pkt_dev->labels[n]), 1507 "%08x%s", ntohl(pkt_dev->labels[n]),
1447 n == pkt_dev->nr_labels-1 ? "" : ","); 1508 n == pkt_dev->nr_labels-1 ? "" : ",");
1509
1510 if (pkt_dev->nr_labels && pkt_dev->vlan_id != 0xffff) {
1511 pkt_dev->vlan_id = 0xffff; /* turn off VLAN/SVLAN */
1512 pkt_dev->svlan_id = 0xffff;
1513
1514 if (debug)
1515 printk("pktgen: VLAN/SVLAN auto turned off\n");
1516 }
1517 return count;
1518 }
1519
1520 if (!strcmp(name, "vlan_id")) {
1521 len = num_arg(&user_buffer[i], 4, &value);
1522 if (len < 0) {
1523 return len;
1524 }
1525 i += len;
1526 if (value <= 4095) {
1527 pkt_dev->vlan_id = value; /* turn on VLAN */
1528
1529 if (debug)
1530 printk("pktgen: VLAN turned on\n");
1531
1532 if (debug && pkt_dev->nr_labels)
1533 printk("pktgen: MPLS auto turned off\n");
1534
1535 pkt_dev->nr_labels = 0; /* turn off MPLS */
1536 sprintf(pg_result, "OK: vlan_id=%u", pkt_dev->vlan_id);
1537 } else {
1538 pkt_dev->vlan_id = 0xffff; /* turn off VLAN/SVLAN */
1539 pkt_dev->svlan_id = 0xffff;
1540
1541 if (debug)
1542 printk("pktgen: VLAN/SVLAN turned off\n");
1543 }
1544 return count;
1545 }
1546
1547 if (!strcmp(name, "vlan_p")) {
1548 len = num_arg(&user_buffer[i], 1, &value);
1549 if (len < 0) {
1550 return len;
1551 }
1552 i += len;
1553 if ((value <= 7) && (pkt_dev->vlan_id != 0xffff)) {
1554 pkt_dev->vlan_p = value;
1555 sprintf(pg_result, "OK: vlan_p=%u", pkt_dev->vlan_p);
1556 } else {
1557 sprintf(pg_result, "ERROR: vlan_p must be 0-7");
1558 }
1559 return count;
1560 }
1561
1562 if (!strcmp(name, "vlan_cfi")) {
1563 len = num_arg(&user_buffer[i], 1, &value);
1564 if (len < 0) {
1565 return len;
1566 }
1567 i += len;
1568 if ((value <= 1) && (pkt_dev->vlan_id != 0xffff)) {
1569 pkt_dev->vlan_cfi = value;
1570 sprintf(pg_result, "OK: vlan_cfi=%u", pkt_dev->vlan_cfi);
1571 } else {
1572 sprintf(pg_result, "ERROR: vlan_cfi must be 0-1");
1573 }
1574 return count;
1575 }
1576
1577 if (!strcmp(name, "svlan_id")) {
1578 len = num_arg(&user_buffer[i], 4, &value);
1579 if (len < 0) {
1580 return len;
1581 }
1582 i += len;
1583 if ((value <= 4095) && ((pkt_dev->vlan_id != 0xffff))) {
1584 pkt_dev->svlan_id = value; /* turn on SVLAN */
1585
1586 if (debug)
1587 printk("pktgen: SVLAN turned on\n");
1588
1589 if (debug && pkt_dev->nr_labels)
1590 printk("pktgen: MPLS auto turned off\n");
1591
1592 pkt_dev->nr_labels = 0; /* turn off MPLS */
1593 sprintf(pg_result, "OK: svlan_id=%u", pkt_dev->svlan_id);
1594 } else {
1595 pkt_dev->vlan_id = 0xffff; /* turn off VLAN/SVLAN */
1596 pkt_dev->svlan_id = 0xffff;
1597
1598 if (debug)
1599 printk("pktgen: VLAN/SVLAN turned off\n");
1600 }
1601 return count;
1602 }
1603
1604 if (!strcmp(name, "svlan_p")) {
1605 len = num_arg(&user_buffer[i], 1, &value);
1606 if (len < 0) {
1607 return len;
1608 }
1609 i += len;
1610 if ((value <= 7) && (pkt_dev->svlan_id != 0xffff)) {
1611 pkt_dev->svlan_p = value;
1612 sprintf(pg_result, "OK: svlan_p=%u", pkt_dev->svlan_p);
1613 } else {
1614 sprintf(pg_result, "ERROR: svlan_p must be 0-7");
1615 }
1616 return count;
1617 }
1618
1619 if (!strcmp(name, "svlan_cfi")) {
1620 len = num_arg(&user_buffer[i], 1, &value);
1621 if (len < 0) {
1622 return len;
1623 }
1624 i += len;
1625 if ((value <= 1) && (pkt_dev->svlan_id != 0xffff)) {
1626 pkt_dev->svlan_cfi = value;
1627 sprintf(pg_result, "OK: svlan_cfi=%u", pkt_dev->svlan_cfi);
1628 } else {
1629 sprintf(pg_result, "ERROR: svlan_cfi must be 0-1");
1630 }
1631 return count;
1632 }
1633
1634 if (!strcmp(name, "tos")) {
1635 __u32 tmp_value = 0;
1636 len = hex32_arg(&user_buffer[i], 2, &tmp_value);
1637 if (len < 0) {
1638 return len;
1639 }
1640 i += len;
1641 if (len == 2) {
1642 pkt_dev->tos = tmp_value;
1643 sprintf(pg_result, "OK: tos=0x%02x", pkt_dev->tos);
1644 } else {
1645 sprintf(pg_result, "ERROR: tos must be 00-ff");
1646 }
1647 return count;
1648 }
1649
1650 if (!strcmp(name, "traffic_class")) {
1651 __u32 tmp_value = 0;
1652 len = hex32_arg(&user_buffer[i], 2, &tmp_value);
1653 if (len < 0) {
1654 return len;
1655 }
1656 i += len;
1657 if (len == 2) {
1658 pkt_dev->traffic_class = tmp_value;
1659 sprintf(pg_result, "OK: traffic_class=0x%02x", pkt_dev->traffic_class);
1660 } else {
1661 sprintf(pg_result, "ERROR: traffic_class must be 00-ff");
1662 }
1448 return count; 1663 return count;
1449 } 1664 }
1450 1665
@@ -1949,6 +2164,14 @@ static void mod_cur_headers(struct pktgen_dev *pkt_dev)
1949 htonl(0x000fffff)); 2164 htonl(0x000fffff));
1950 } 2165 }
1951 2166
2167 if ((pkt_dev->flags & F_VID_RND) && (pkt_dev->vlan_id != 0xffff)) {
2168 pkt_dev->vlan_id = pktgen_random() % 4096;
2169 }
2170
2171 if ((pkt_dev->flags & F_SVID_RND) && (pkt_dev->svlan_id != 0xffff)) {
2172 pkt_dev->svlan_id = pktgen_random() % 4096;
2173 }
2174
1952 if (pkt_dev->udp_src_min < pkt_dev->udp_src_max) { 2175 if (pkt_dev->udp_src_min < pkt_dev->udp_src_max) {
1953 if (pkt_dev->flags & F_UDPSRC_RND) 2176 if (pkt_dev->flags & F_UDPSRC_RND)
1954 pkt_dev->cur_udp_src = 2177 pkt_dev->cur_udp_src =
@@ -2092,10 +2315,18 @@ static struct sk_buff *fill_packet_ipv4(struct net_device *odev,
2092 struct pktgen_hdr *pgh = NULL; 2315 struct pktgen_hdr *pgh = NULL;
2093 __be16 protocol = __constant_htons(ETH_P_IP); 2316 __be16 protocol = __constant_htons(ETH_P_IP);
2094 __be32 *mpls; 2317 __be32 *mpls;
2318 __be16 *vlan_tci = NULL; /* Encapsulates priority and VLAN ID */
2319 __be16 *vlan_encapsulated_proto = NULL; /* packet type ID field (or len) for VLAN tag */
2320 __be16 *svlan_tci = NULL; /* Encapsulates priority and SVLAN ID */
2321 __be16 *svlan_encapsulated_proto = NULL; /* packet type ID field (or len) for SVLAN tag */
2322
2095 2323
2096 if (pkt_dev->nr_labels) 2324 if (pkt_dev->nr_labels)
2097 protocol = __constant_htons(ETH_P_MPLS_UC); 2325 protocol = __constant_htons(ETH_P_MPLS_UC);
2098 2326
2327 if (pkt_dev->vlan_id != 0xffff)
2328 protocol = __constant_htons(ETH_P_8021Q);
2329
2099 /* Update any of the values, used when we're incrementing various 2330 /* Update any of the values, used when we're incrementing various
2100 * fields. 2331 * fields.
2101 */ 2332 */
@@ -2103,7 +2334,9 @@ static struct sk_buff *fill_packet_ipv4(struct net_device *odev,
2103 2334
2104 datalen = (odev->hard_header_len + 16) & ~0xf; 2335 datalen = (odev->hard_header_len + 16) & ~0xf;
2105 skb = alloc_skb(pkt_dev->cur_pkt_size + 64 + datalen + 2336 skb = alloc_skb(pkt_dev->cur_pkt_size + 64 + datalen +
2106 pkt_dev->nr_labels*sizeof(u32), GFP_ATOMIC); 2337 pkt_dev->nr_labels*sizeof(u32) +
2338 VLAN_TAG_SIZE(pkt_dev) + SVLAN_TAG_SIZE(pkt_dev),
2339 GFP_ATOMIC);
2107 if (!skb) { 2340 if (!skb) {
2108 sprintf(pkt_dev->result, "No memory"); 2341 sprintf(pkt_dev->result, "No memory");
2109 return NULL; 2342 return NULL;
@@ -2116,6 +2349,24 @@ static struct sk_buff *fill_packet_ipv4(struct net_device *odev,
2116 mpls = (__be32 *)skb_put(skb, pkt_dev->nr_labels*sizeof(__u32)); 2349 mpls = (__be32 *)skb_put(skb, pkt_dev->nr_labels*sizeof(__u32));
2117 if (pkt_dev->nr_labels) 2350 if (pkt_dev->nr_labels)
2118 mpls_push(mpls, pkt_dev); 2351 mpls_push(mpls, pkt_dev);
2352
2353 if (pkt_dev->vlan_id != 0xffff) {
2354 if(pkt_dev->svlan_id != 0xffff) {
2355 svlan_tci = (__be16 *)skb_put(skb, sizeof(__be16));
2356 *svlan_tci = htons(pkt_dev->svlan_id);
2357 *svlan_tci |= pkt_dev->svlan_p << 5;
2358 *svlan_tci |= pkt_dev->svlan_cfi << 4;
2359 svlan_encapsulated_proto = (__be16 *)skb_put(skb, sizeof(__be16));
2360 *svlan_encapsulated_proto = __constant_htons(ETH_P_8021Q);
2361 }
2362 vlan_tci = (__be16 *)skb_put(skb, sizeof(__be16));
2363 *vlan_tci = htons(pkt_dev->vlan_id);
2364 *vlan_tci |= pkt_dev->vlan_p << 5;
2365 *vlan_tci |= pkt_dev->vlan_cfi << 4;
2366 vlan_encapsulated_proto = (__be16 *)skb_put(skb, sizeof(__be16));
2367 *vlan_encapsulated_proto = __constant_htons(ETH_P_IP);
2368 }
2369
2119 iph = (struct iphdr *)skb_put(skb, sizeof(struct iphdr)); 2370 iph = (struct iphdr *)skb_put(skb, sizeof(struct iphdr));
2120 udph = (struct udphdr *)skb_put(skb, sizeof(struct udphdr)); 2371 udph = (struct udphdr *)skb_put(skb, sizeof(struct udphdr));
2121 2372
@@ -2124,7 +2375,7 @@ static struct sk_buff *fill_packet_ipv4(struct net_device *odev,
2124 2375
2125 /* Eth + IPh + UDPh + mpls */ 2376 /* Eth + IPh + UDPh + mpls */
2126 datalen = pkt_dev->cur_pkt_size - 14 - 20 - 8 - 2377 datalen = pkt_dev->cur_pkt_size - 14 - 20 - 8 -
2127 pkt_dev->nr_labels*sizeof(u32); 2378 pkt_dev->nr_labels*sizeof(u32) - VLAN_TAG_SIZE(pkt_dev) - SVLAN_TAG_SIZE(pkt_dev);
2128 if (datalen < sizeof(struct pktgen_hdr)) 2379 if (datalen < sizeof(struct pktgen_hdr))
2129 datalen = sizeof(struct pktgen_hdr); 2380 datalen = sizeof(struct pktgen_hdr);
2130 2381
@@ -2136,7 +2387,7 @@ static struct sk_buff *fill_packet_ipv4(struct net_device *odev,
2136 iph->ihl = 5; 2387 iph->ihl = 5;
2137 iph->version = 4; 2388 iph->version = 4;
2138 iph->ttl = 32; 2389 iph->ttl = 32;
2139 iph->tos = 0; 2390 iph->tos = pkt_dev->tos;
2140 iph->protocol = IPPROTO_UDP; /* UDP */ 2391 iph->protocol = IPPROTO_UDP; /* UDP */
2141 iph->saddr = pkt_dev->cur_saddr; 2392 iph->saddr = pkt_dev->cur_saddr;
2142 iph->daddr = pkt_dev->cur_daddr; 2393 iph->daddr = pkt_dev->cur_daddr;
@@ -2146,7 +2397,8 @@ static struct sk_buff *fill_packet_ipv4(struct net_device *odev,
2146 iph->check = 0; 2397 iph->check = 0;
2147 iph->check = ip_fast_csum((void *)iph, iph->ihl); 2398 iph->check = ip_fast_csum((void *)iph, iph->ihl);
2148 skb->protocol = protocol; 2399 skb->protocol = protocol;
2149 skb->mac.raw = ((u8 *) iph) - 14 - pkt_dev->nr_labels*sizeof(u32); 2400 skb->mac.raw = ((u8 *) iph) - 14 - pkt_dev->nr_labels*sizeof(u32) -
2401 VLAN_TAG_SIZE(pkt_dev) - SVLAN_TAG_SIZE(pkt_dev);
2150 skb->dev = odev; 2402 skb->dev = odev;
2151 skb->pkt_type = PACKET_HOST; 2403 skb->pkt_type = PACKET_HOST;
2152 skb->nh.iph = iph; 2404 skb->nh.iph = iph;
@@ -2218,7 +2470,6 @@ static struct sk_buff *fill_packet_ipv4(struct net_device *odev,
2218 pgh->tv_sec = htonl(timestamp.tv_sec); 2470 pgh->tv_sec = htonl(timestamp.tv_sec);
2219 pgh->tv_usec = htonl(timestamp.tv_usec); 2471 pgh->tv_usec = htonl(timestamp.tv_usec);
2220 } 2472 }
2221 pkt_dev->seq_num++;
2222 2473
2223 return skb; 2474 return skb;
2224} 2475}
@@ -2402,17 +2653,26 @@ static struct sk_buff *fill_packet_ipv6(struct net_device *odev,
2402 struct pktgen_hdr *pgh = NULL; 2653 struct pktgen_hdr *pgh = NULL;
2403 __be16 protocol = __constant_htons(ETH_P_IPV6); 2654 __be16 protocol = __constant_htons(ETH_P_IPV6);
2404 __be32 *mpls; 2655 __be32 *mpls;
2656 __be16 *vlan_tci = NULL; /* Encapsulates priority and VLAN ID */
2657 __be16 *vlan_encapsulated_proto = NULL; /* packet type ID field (or len) for VLAN tag */
2658 __be16 *svlan_tci = NULL; /* Encapsulates priority and SVLAN ID */
2659 __be16 *svlan_encapsulated_proto = NULL; /* packet type ID field (or len) for SVLAN tag */
2405 2660
2406 if (pkt_dev->nr_labels) 2661 if (pkt_dev->nr_labels)
2407 protocol = __constant_htons(ETH_P_MPLS_UC); 2662 protocol = __constant_htons(ETH_P_MPLS_UC);
2408 2663
2664 if (pkt_dev->vlan_id != 0xffff)
2665 protocol = __constant_htons(ETH_P_8021Q);
2666
2409 /* Update any of the values, used when we're incrementing various 2667 /* Update any of the values, used when we're incrementing various
2410 * fields. 2668 * fields.
2411 */ 2669 */
2412 mod_cur_headers(pkt_dev); 2670 mod_cur_headers(pkt_dev);
2413 2671
2414 skb = alloc_skb(pkt_dev->cur_pkt_size + 64 + 16 + 2672 skb = alloc_skb(pkt_dev->cur_pkt_size + 64 + 16 +
2415 pkt_dev->nr_labels*sizeof(u32), GFP_ATOMIC); 2673 pkt_dev->nr_labels*sizeof(u32) +
2674 VLAN_TAG_SIZE(pkt_dev) + SVLAN_TAG_SIZE(pkt_dev),
2675 GFP_ATOMIC);
2416 if (!skb) { 2676 if (!skb) {
2417 sprintf(pkt_dev->result, "No memory"); 2677 sprintf(pkt_dev->result, "No memory");
2418 return NULL; 2678 return NULL;
@@ -2425,16 +2685,34 @@ static struct sk_buff *fill_packet_ipv6(struct net_device *odev,
2425 mpls = (__be32 *)skb_put(skb, pkt_dev->nr_labels*sizeof(__u32)); 2685 mpls = (__be32 *)skb_put(skb, pkt_dev->nr_labels*sizeof(__u32));
2426 if (pkt_dev->nr_labels) 2686 if (pkt_dev->nr_labels)
2427 mpls_push(mpls, pkt_dev); 2687 mpls_push(mpls, pkt_dev);
2688
2689 if (pkt_dev->vlan_id != 0xffff) {
2690 if(pkt_dev->svlan_id != 0xffff) {
2691 svlan_tci = (__be16 *)skb_put(skb, sizeof(__be16));
2692 *svlan_tci = htons(pkt_dev->svlan_id);
2693 *svlan_tci |= pkt_dev->svlan_p << 5;
2694 *svlan_tci |= pkt_dev->svlan_cfi << 4;
2695 svlan_encapsulated_proto = (__be16 *)skb_put(skb, sizeof(__be16));
2696 *svlan_encapsulated_proto = __constant_htons(ETH_P_8021Q);
2697 }
2698 vlan_tci = (__be16 *)skb_put(skb, sizeof(__be16));
2699 *vlan_tci = htons(pkt_dev->vlan_id);
2700 *vlan_tci |= pkt_dev->vlan_p << 5;
2701 *vlan_tci |= pkt_dev->vlan_cfi << 4;
2702 vlan_encapsulated_proto = (__be16 *)skb_put(skb, sizeof(__be16));
2703 *vlan_encapsulated_proto = __constant_htons(ETH_P_IPV6);
2704 }
2705
2428 iph = (struct ipv6hdr *)skb_put(skb, sizeof(struct ipv6hdr)); 2706 iph = (struct ipv6hdr *)skb_put(skb, sizeof(struct ipv6hdr));
2429 udph = (struct udphdr *)skb_put(skb, sizeof(struct udphdr)); 2707 udph = (struct udphdr *)skb_put(skb, sizeof(struct udphdr));
2430 2708
2431 memcpy(eth, pkt_dev->hh, 12); 2709 memcpy(eth, pkt_dev->hh, 12);
2432 *(u16 *) & eth[12] = __constant_htons(ETH_P_IPV6); 2710 *(u16 *) & eth[12] = protocol;
2433 2711
2434 /* Eth + IPh + UDPh + mpls */ 2712 /* Eth + IPh + UDPh + mpls */
2435 datalen = pkt_dev->cur_pkt_size - 14 - 2713 datalen = pkt_dev->cur_pkt_size - 14 -
2436 sizeof(struct ipv6hdr) - sizeof(struct udphdr) - 2714 sizeof(struct ipv6hdr) - sizeof(struct udphdr) -
2437 pkt_dev->nr_labels*sizeof(u32); 2715 pkt_dev->nr_labels*sizeof(u32) - VLAN_TAG_SIZE(pkt_dev) - SVLAN_TAG_SIZE(pkt_dev);
2438 2716
2439 if (datalen < sizeof(struct pktgen_hdr)) { 2717 if (datalen < sizeof(struct pktgen_hdr)) {
2440 datalen = sizeof(struct pktgen_hdr); 2718 datalen = sizeof(struct pktgen_hdr);
@@ -2450,6 +2728,11 @@ static struct sk_buff *fill_packet_ipv6(struct net_device *odev,
2450 2728
2451 *(u32 *) iph = __constant_htonl(0x60000000); /* Version + flow */ 2729 *(u32 *) iph = __constant_htonl(0x60000000); /* Version + flow */
2452 2730
2731 if (pkt_dev->traffic_class) {
2732 /* Version + traffic class + flow (0) */
2733 *(u32 *)iph |= htonl(0x60000000 | (pkt_dev->traffic_class << 20));
2734 }
2735
2453 iph->hop_limit = 32; 2736 iph->hop_limit = 32;
2454 2737
2455 iph->payload_len = htons(sizeof(struct udphdr) + datalen); 2738 iph->payload_len = htons(sizeof(struct udphdr) + datalen);
@@ -2458,7 +2741,8 @@ static struct sk_buff *fill_packet_ipv6(struct net_device *odev,
2458 ipv6_addr_copy(&iph->daddr, &pkt_dev->cur_in6_daddr); 2741 ipv6_addr_copy(&iph->daddr, &pkt_dev->cur_in6_daddr);
2459 ipv6_addr_copy(&iph->saddr, &pkt_dev->cur_in6_saddr); 2742 ipv6_addr_copy(&iph->saddr, &pkt_dev->cur_in6_saddr);
2460 2743
2461 skb->mac.raw = ((u8 *) iph) - 14 - pkt_dev->nr_labels*sizeof(u32); 2744 skb->mac.raw = ((u8 *) iph) - 14 - pkt_dev->nr_labels*sizeof(u32) -
2745 VLAN_TAG_SIZE(pkt_dev) - SVLAN_TAG_SIZE(pkt_dev);
2462 skb->protocol = protocol; 2746 skb->protocol = protocol;
2463 skb->dev = odev; 2747 skb->dev = odev;
2464 skb->pkt_type = PACKET_HOST; 2748 skb->pkt_type = PACKET_HOST;
@@ -2531,7 +2815,7 @@ static struct sk_buff *fill_packet_ipv6(struct net_device *odev,
2531 pgh->tv_sec = htonl(timestamp.tv_sec); 2815 pgh->tv_sec = htonl(timestamp.tv_sec);
2532 pgh->tv_usec = htonl(timestamp.tv_usec); 2816 pgh->tv_usec = htonl(timestamp.tv_usec);
2533 } 2817 }
2534 pkt_dev->seq_num++; 2818 /* pkt_dev->seq_num++; FF: you really mean this? */
2535 2819
2536 return skb; 2820 return skb;
2537} 2821}
@@ -3177,6 +3461,13 @@ static int pktgen_add_device(struct pktgen_thread *t, const char *ifname)
3177 pkt_dev->udp_dst_min = 9; 3461 pkt_dev->udp_dst_min = 9;
3178 pkt_dev->udp_dst_max = 9; 3462 pkt_dev->udp_dst_max = 9;
3179 3463
3464 pkt_dev->vlan_p = 0;
3465 pkt_dev->vlan_cfi = 0;
3466 pkt_dev->vlan_id = 0xffff;
3467 pkt_dev->svlan_p = 0;
3468 pkt_dev->svlan_cfi = 0;
3469 pkt_dev->svlan_id = 0xffff;
3470
3180 strncpy(pkt_dev->ifname, ifname, IFNAMSIZ); 3471 strncpy(pkt_dev->ifname, ifname, IFNAMSIZ);
3181 3472
3182 if (!pktgen_setup_dev(pkt_dev)) { 3473 if (!pktgen_setup_dev(pkt_dev)) {
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index d8e25e08cb7e..221e4038216b 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -562,7 +562,7 @@ static int rtnl_getlink(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg)
562 562
563 err = nlmsg_parse(nlh, sizeof(*ifm), tb, IFLA_MAX, ifla_policy); 563 err = nlmsg_parse(nlh, sizeof(*ifm), tb, IFLA_MAX, ifla_policy);
564 if (err < 0) 564 if (err < 0)
565 goto errout; 565 return err;
566 566
567 ifm = nlmsg_data(nlh); 567 ifm = nlmsg_data(nlh);
568 if (ifm->ifi_index >= 0) { 568 if (ifm->ifi_index >= 0) {
diff --git a/net/core/utils.c b/net/core/utils.c
index 2682490777de..94c5d761c830 100644
--- a/net/core/utils.c
+++ b/net/core/utils.c
@@ -3,7 +3,7 @@
3 * 3 *
4 * Authors: 4 * Authors:
5 * net_random Alan Cox 5 * net_random Alan Cox
6 * net_ratelimit Andy Kleen 6 * net_ratelimit Andi Kleen
7 * in{4,6}_pton YOSHIFUJI Hideaki, Copyright (C)2006 USAGI/WIDE Project 7 * in{4,6}_pton YOSHIFUJI Hideaki, Copyright (C)2006 USAGI/WIDE Project
8 * 8 *
9 * Created by Alexey Kuznetsov <kuznet@ms2.inr.ac.ru> 9 * Created by Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>
diff --git a/net/dccp/ipv4.c b/net/dccp/ipv4.c
index 66be29b6f508..bf692c1c116f 100644
--- a/net/dccp/ipv4.c
+++ b/net/dccp/ipv4.c
@@ -50,7 +50,7 @@ int dccp_v4_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len)
50 struct dccp_sock *dp = dccp_sk(sk); 50 struct dccp_sock *dp = dccp_sk(sk);
51 const struct sockaddr_in *usin = (struct sockaddr_in *)uaddr; 51 const struct sockaddr_in *usin = (struct sockaddr_in *)uaddr;
52 struct rtable *rt; 52 struct rtable *rt;
53 u32 daddr, nexthop; 53 __be32 daddr, nexthop;
54 int tmp; 54 int tmp;
55 int err; 55 int err;
56 56
diff --git a/net/ethernet/eth.c b/net/ethernet/eth.c
index 43863933f27f..4bd78c8cfb26 100644
--- a/net/ethernet/eth.c
+++ b/net/ethernet/eth.c
@@ -223,7 +223,7 @@ static int eth_header_parse(struct sk_buff *skb, unsigned char *haddr)
223 */ 223 */
224int eth_header_cache(struct neighbour *neigh, struct hh_cache *hh) 224int eth_header_cache(struct neighbour *neigh, struct hh_cache *hh)
225{ 225{
226 unsigned short type = hh->hh_type; 226 __be16 type = hh->hh_type;
227 struct ethhdr *eth; 227 struct ethhdr *eth;
228 struct net_device *dev = neigh->dev; 228 struct net_device *dev = neigh->dev;
229 229
diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
index fdd89e37b9aa..edcf0932ac6d 100644
--- a/net/ipv4/af_inet.c
+++ b/net/ipv4/af_inet.c
@@ -996,7 +996,7 @@ static int inet_sk_reselect_saddr(struct sock *sk)
996 struct rtable *rt; 996 struct rtable *rt;
997 __u32 old_saddr = inet->saddr; 997 __u32 old_saddr = inet->saddr;
998 __u32 new_saddr; 998 __u32 new_saddr;
999 __u32 daddr = inet->daddr; 999 __be32 daddr = inet->daddr;
1000 1000
1001 if (inet->opt && inet->opt->srr) 1001 if (inet->opt && inet->opt->srr)
1002 daddr = inet->opt->faddr; 1002 daddr = inet->opt->faddr;
@@ -1043,7 +1043,7 @@ int inet_sk_rebuild_header(struct sock *sk)
1043{ 1043{
1044 struct inet_sock *inet = inet_sk(sk); 1044 struct inet_sock *inet = inet_sk(sk);
1045 struct rtable *rt = (struct rtable *)__sk_dst_check(sk, 0); 1045 struct rtable *rt = (struct rtable *)__sk_dst_check(sk, 0);
1046 u32 daddr; 1046 __be32 daddr;
1047 int err; 1047 int err;
1048 1048
1049 /* Route is OK, nothing to do. */ 1049 /* Route is OK, nothing to do. */
@@ -1342,10 +1342,10 @@ static int __init inet_init(void)
1342 rc = 0; 1342 rc = 0;
1343out: 1343out:
1344 return rc; 1344 return rc;
1345out_unregister_tcp_proto:
1346 proto_unregister(&tcp_prot);
1347out_unregister_udp_proto: 1345out_unregister_udp_proto:
1348 proto_unregister(&udp_prot); 1346 proto_unregister(&udp_prot);
1347out_unregister_tcp_proto:
1348 proto_unregister(&tcp_prot);
1349 goto out; 1349 goto out;
1350} 1350}
1351 1351
diff --git a/net/ipv4/arp.c b/net/ipv4/arp.c
index c8a3723bc001..cfe5c8474286 100644
--- a/net/ipv4/arp.c
+++ b/net/ipv4/arp.c
@@ -234,7 +234,7 @@ static u32 arp_hash(const void *pkey, const struct net_device *dev)
234 234
235static int arp_constructor(struct neighbour *neigh) 235static int arp_constructor(struct neighbour *neigh)
236{ 236{
237 u32 addr = *(u32*)neigh->primary_key; 237 __be32 addr = *(__be32*)neigh->primary_key;
238 struct net_device *dev = neigh->dev; 238 struct net_device *dev = neigh->dev;
239 struct in_device *in_dev; 239 struct in_device *in_dev;
240 struct neigh_parms *parms; 240 struct neigh_parms *parms;
@@ -330,10 +330,10 @@ static void arp_error_report(struct neighbour *neigh, struct sk_buff *skb)
330 330
331static void arp_solicit(struct neighbour *neigh, struct sk_buff *skb) 331static void arp_solicit(struct neighbour *neigh, struct sk_buff *skb)
332{ 332{
333 u32 saddr = 0; 333 __be32 saddr = 0;
334 u8 *dst_ha = NULL; 334 u8 *dst_ha = NULL;
335 struct net_device *dev = neigh->dev; 335 struct net_device *dev = neigh->dev;
336 u32 target = *(u32*)neigh->primary_key; 336 __be32 target = *(__be32*)neigh->primary_key;
337 int probes = atomic_read(&neigh->probes); 337 int probes = atomic_read(&neigh->probes);
338 struct in_device *in_dev = in_dev_get(dev); 338 struct in_device *in_dev = in_dev_get(dev);
339 339
@@ -385,7 +385,7 @@ static void arp_solicit(struct neighbour *neigh, struct sk_buff *skb)
385} 385}
386 386
387static int arp_ignore(struct in_device *in_dev, struct net_device *dev, 387static int arp_ignore(struct in_device *in_dev, struct net_device *dev,
388 u32 sip, u32 tip) 388 __be32 sip, __be32 tip)
389{ 389{
390 int scope; 390 int scope;
391 391
@@ -420,7 +420,7 @@ static int arp_ignore(struct in_device *in_dev, struct net_device *dev,
420 return !inet_confirm_addr(dev, sip, tip, scope); 420 return !inet_confirm_addr(dev, sip, tip, scope);
421} 421}
422 422
423static int arp_filter(__u32 sip, __u32 tip, struct net_device *dev) 423static int arp_filter(__be32 sip, __be32 tip, struct net_device *dev)
424{ 424{
425 struct flowi fl = { .nl_u = { .ip4_u = { .daddr = sip, 425 struct flowi fl = { .nl_u = { .ip4_u = { .daddr = sip,
426 .saddr = tip } } }; 426 .saddr = tip } } };
@@ -449,7 +449,7 @@ static int arp_filter(__u32 sip, __u32 tip, struct net_device *dev)
449 * is allowed to use this function, it is scheduled to be removed. --ANK 449 * is allowed to use this function, it is scheduled to be removed. --ANK
450 */ 450 */
451 451
452static int arp_set_predefined(int addr_hint, unsigned char * haddr, u32 paddr, struct net_device * dev) 452static int arp_set_predefined(int addr_hint, unsigned char * haddr, __be32 paddr, struct net_device * dev)
453{ 453{
454 switch (addr_hint) { 454 switch (addr_hint) {
455 case RTN_LOCAL: 455 case RTN_LOCAL:
@@ -470,7 +470,7 @@ static int arp_set_predefined(int addr_hint, unsigned char * haddr, u32 paddr, s
470int arp_find(unsigned char *haddr, struct sk_buff *skb) 470int arp_find(unsigned char *haddr, struct sk_buff *skb)
471{ 471{
472 struct net_device *dev = skb->dev; 472 struct net_device *dev = skb->dev;
473 u32 paddr; 473 __be32 paddr;
474 struct neighbour *n; 474 struct neighbour *n;
475 475
476 if (!skb->dst) { 476 if (!skb->dst) {
@@ -511,7 +511,7 @@ int arp_bind_neighbour(struct dst_entry *dst)
511 if (dev == NULL) 511 if (dev == NULL)
512 return -EINVAL; 512 return -EINVAL;
513 if (n == NULL) { 513 if (n == NULL) {
514 u32 nexthop = ((struct rtable*)dst)->rt_gateway; 514 __be32 nexthop = ((struct rtable*)dst)->rt_gateway;
515 if (dev->flags&(IFF_LOOPBACK|IFF_POINTOPOINT)) 515 if (dev->flags&(IFF_LOOPBACK|IFF_POINTOPOINT))
516 nexthop = 0; 516 nexthop = 0;
517 n = __neigh_lookup_errno( 517 n = __neigh_lookup_errno(
@@ -560,8 +560,8 @@ static inline int arp_fwd_proxy(struct in_device *in_dev, struct rtable *rt)
560 * Create an arp packet. If (dest_hw == NULL), we create a broadcast 560 * Create an arp packet. If (dest_hw == NULL), we create a broadcast
561 * message. 561 * message.
562 */ 562 */
563struct sk_buff *arp_create(int type, int ptype, u32 dest_ip, 563struct sk_buff *arp_create(int type, int ptype, __be32 dest_ip,
564 struct net_device *dev, u32 src_ip, 564 struct net_device *dev, __be32 src_ip,
565 unsigned char *dest_hw, unsigned char *src_hw, 565 unsigned char *dest_hw, unsigned char *src_hw,
566 unsigned char *target_hw) 566 unsigned char *target_hw)
567{ 567{
@@ -675,8 +675,8 @@ void arp_xmit(struct sk_buff *skb)
675/* 675/*
676 * Create and send an arp packet. 676 * Create and send an arp packet.
677 */ 677 */
678void arp_send(int type, int ptype, u32 dest_ip, 678void arp_send(int type, int ptype, __be32 dest_ip,
679 struct net_device *dev, u32 src_ip, 679 struct net_device *dev, __be32 src_ip,
680 unsigned char *dest_hw, unsigned char *src_hw, 680 unsigned char *dest_hw, unsigned char *src_hw,
681 unsigned char *target_hw) 681 unsigned char *target_hw)
682{ 682{
@@ -710,7 +710,7 @@ static int arp_process(struct sk_buff *skb)
710 unsigned char *arp_ptr; 710 unsigned char *arp_ptr;
711 struct rtable *rt; 711 struct rtable *rt;
712 unsigned char *sha, *tha; 712 unsigned char *sha, *tha;
713 u32 sip, tip; 713 __be32 sip, tip;
714 u16 dev_type = dev->type; 714 u16 dev_type = dev->type;
715 int addr_type; 715 int addr_type;
716 struct neighbour *n; 716 struct neighbour *n;
@@ -969,13 +969,13 @@ out_of_mem:
969 969
970static int arp_req_set(struct arpreq *r, struct net_device * dev) 970static int arp_req_set(struct arpreq *r, struct net_device * dev)
971{ 971{
972 u32 ip = ((struct sockaddr_in *) &r->arp_pa)->sin_addr.s_addr; 972 __be32 ip = ((struct sockaddr_in *) &r->arp_pa)->sin_addr.s_addr;
973 struct neighbour *neigh; 973 struct neighbour *neigh;
974 int err; 974 int err;
975 975
976 if (r->arp_flags&ATF_PUBL) { 976 if (r->arp_flags&ATF_PUBL) {
977 u32 mask = ((struct sockaddr_in *) &r->arp_netmask)->sin_addr.s_addr; 977 __be32 mask = ((struct sockaddr_in *) &r->arp_netmask)->sin_addr.s_addr;
978 if (mask && mask != 0xFFFFFFFF) 978 if (mask && mask != htonl(0xFFFFFFFF))
979 return -EINVAL; 979 return -EINVAL;
980 if (!dev && (r->arp_flags & ATF_COM)) { 980 if (!dev && (r->arp_flags & ATF_COM)) {
981 dev = dev_getbyhwaddr(r->arp_ha.sa_family, r->arp_ha.sa_data); 981 dev = dev_getbyhwaddr(r->arp_ha.sa_family, r->arp_ha.sa_data);
@@ -1063,7 +1063,7 @@ static unsigned arp_state_to_flags(struct neighbour *neigh)
1063 1063
1064static int arp_req_get(struct arpreq *r, struct net_device *dev) 1064static int arp_req_get(struct arpreq *r, struct net_device *dev)
1065{ 1065{
1066 u32 ip = ((struct sockaddr_in *) &r->arp_pa)->sin_addr.s_addr; 1066 __be32 ip = ((struct sockaddr_in *) &r->arp_pa)->sin_addr.s_addr;
1067 struct neighbour *neigh; 1067 struct neighbour *neigh;
1068 int err = -ENXIO; 1068 int err = -ENXIO;
1069 1069
@@ -1084,13 +1084,13 @@ static int arp_req_get(struct arpreq *r, struct net_device *dev)
1084static int arp_req_delete(struct arpreq *r, struct net_device * dev) 1084static int arp_req_delete(struct arpreq *r, struct net_device * dev)
1085{ 1085{
1086 int err; 1086 int err;
1087 u32 ip = ((struct sockaddr_in *)&r->arp_pa)->sin_addr.s_addr; 1087 __be32 ip = ((struct sockaddr_in *)&r->arp_pa)->sin_addr.s_addr;
1088 struct neighbour *neigh; 1088 struct neighbour *neigh;
1089 1089
1090 if (r->arp_flags & ATF_PUBL) { 1090 if (r->arp_flags & ATF_PUBL) {
1091 u32 mask = 1091 __be32 mask =
1092 ((struct sockaddr_in *)&r->arp_netmask)->sin_addr.s_addr; 1092 ((struct sockaddr_in *)&r->arp_netmask)->sin_addr.s_addr;
1093 if (mask == 0xFFFFFFFF) 1093 if (mask == htonl(0xFFFFFFFF))
1094 return pneigh_delete(&arp_tbl, &ip, dev); 1094 return pneigh_delete(&arp_tbl, &ip, dev);
1095 if (mask == 0) { 1095 if (mask == 0) {
1096 if (dev == NULL) { 1096 if (dev == NULL) {
diff --git a/net/ipv4/cipso_ipv4.c b/net/ipv4/cipso_ipv4.c
index e6ce0b3ba62a..c4e469ff842d 100644
--- a/net/ipv4/cipso_ipv4.c
+++ b/net/ipv4/cipso_ipv4.c
@@ -474,6 +474,7 @@ doi_add_failure_rlock:
474/** 474/**
475 * cipso_v4_doi_remove - Remove an existing DOI from the CIPSO protocol engine 475 * cipso_v4_doi_remove - Remove an existing DOI from the CIPSO protocol engine
476 * @doi: the DOI value 476 * @doi: the DOI value
477 * @audit_secid: the LSM secid to use in the audit message
477 * @callback: the DOI cleanup/free callback 478 * @callback: the DOI cleanup/free callback
478 * 479 *
479 * Description: 480 * Description:
@@ -483,7 +484,9 @@ doi_add_failure_rlock:
483 * success and negative values on failure. 484 * success and negative values on failure.
484 * 485 *
485 */ 486 */
486int cipso_v4_doi_remove(u32 doi, void (*callback) (struct rcu_head * head)) 487int cipso_v4_doi_remove(u32 doi,
488 u32 audit_secid,
489 void (*callback) (struct rcu_head * head))
487{ 490{
488 struct cipso_v4_doi *doi_def; 491 struct cipso_v4_doi *doi_def;
489 struct cipso_v4_domhsh_entry *dom_iter; 492 struct cipso_v4_domhsh_entry *dom_iter;
@@ -502,7 +505,8 @@ int cipso_v4_doi_remove(u32 doi, void (*callback) (struct rcu_head * head))
502 spin_unlock(&cipso_v4_doi_list_lock); 505 spin_unlock(&cipso_v4_doi_list_lock);
503 list_for_each_entry_rcu(dom_iter, &doi_def->dom_list, list) 506 list_for_each_entry_rcu(dom_iter, &doi_def->dom_list, list)
504 if (dom_iter->valid) 507 if (dom_iter->valid)
505 netlbl_domhsh_remove(dom_iter->domain); 508 netlbl_domhsh_remove(dom_iter->domain,
509 audit_secid);
506 cipso_v4_cache_invalidate(); 510 cipso_v4_cache_invalidate();
507 rcu_read_unlock(); 511 rcu_read_unlock();
508 512
diff --git a/net/ipv4/datagram.c b/net/ipv4/datagram.c
index ec5da4fbd9f4..7b068a891953 100644
--- a/net/ipv4/datagram.c
+++ b/net/ipv4/datagram.c
@@ -25,7 +25,7 @@ int ip4_datagram_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len)
25 struct inet_sock *inet = inet_sk(sk); 25 struct inet_sock *inet = inet_sk(sk);
26 struct sockaddr_in *usin = (struct sockaddr_in *) uaddr; 26 struct sockaddr_in *usin = (struct sockaddr_in *) uaddr;
27 struct rtable *rt; 27 struct rtable *rt;
28 u32 saddr; 28 __be32 saddr;
29 int oif; 29 int oif;
30 int err; 30 int err;
31 31
diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
index 8e8d1f17d77a..7602c79a389b 100644
--- a/net/ipv4/devinet.c
+++ b/net/ipv4/devinet.c
@@ -224,7 +224,7 @@ static void inetdev_destroy(struct in_device *in_dev)
224 call_rcu(&in_dev->rcu_head, in_dev_rcu_put); 224 call_rcu(&in_dev->rcu_head, in_dev_rcu_put);
225} 225}
226 226
227int inet_addr_onlink(struct in_device *in_dev, u32 a, u32 b) 227int inet_addr_onlink(struct in_device *in_dev, __be32 a, __be32 b)
228{ 228{
229 rcu_read_lock(); 229 rcu_read_lock();
230 for_primary_ifa(in_dev) { 230 for_primary_ifa(in_dev) {
@@ -429,8 +429,8 @@ struct in_device *inetdev_by_index(int ifindex)
429 429
430/* Called only from RTNL semaphored context. No locks. */ 430/* Called only from RTNL semaphored context. No locks. */
431 431
432struct in_ifaddr *inet_ifa_byprefix(struct in_device *in_dev, u32 prefix, 432struct in_ifaddr *inet_ifa_byprefix(struct in_device *in_dev, __be32 prefix,
433 u32 mask) 433 __be32 mask)
434{ 434{
435 ASSERT_RTNL(); 435 ASSERT_RTNL();
436 436
@@ -467,7 +467,7 @@ static int inet_rtm_deladdr(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg
467 for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL; 467 for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
468 ifap = &ifa->ifa_next) { 468 ifap = &ifa->ifa_next) {
469 if (tb[IFA_LOCAL] && 469 if (tb[IFA_LOCAL] &&
470 ifa->ifa_local != nla_get_u32(tb[IFA_LOCAL])) 470 ifa->ifa_local != nla_get_be32(tb[IFA_LOCAL]))
471 continue; 471 continue;
472 472
473 if (tb[IFA_LABEL] && nla_strcmp(tb[IFA_LABEL], ifa->ifa_label)) 473 if (tb[IFA_LABEL] && nla_strcmp(tb[IFA_LABEL], ifa->ifa_label))
@@ -475,7 +475,7 @@ static int inet_rtm_deladdr(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg
475 475
476 if (tb[IFA_ADDRESS] && 476 if (tb[IFA_ADDRESS] &&
477 (ifm->ifa_prefixlen != ifa->ifa_prefixlen || 477 (ifm->ifa_prefixlen != ifa->ifa_prefixlen ||
478 !inet_ifa_match(nla_get_u32(tb[IFA_ADDRESS]), ifa))) 478 !inet_ifa_match(nla_get_be32(tb[IFA_ADDRESS]), ifa)))
479 continue; 479 continue;
480 480
481 __inet_del_ifa(in_dev, ifap, 1, nlh, NETLINK_CB(skb).pid); 481 __inet_del_ifa(in_dev, ifap, 1, nlh, NETLINK_CB(skb).pid);
@@ -540,14 +540,14 @@ static struct in_ifaddr *rtm_to_ifaddr(struct nlmsghdr *nlh)
540 ifa->ifa_scope = ifm->ifa_scope; 540 ifa->ifa_scope = ifm->ifa_scope;
541 ifa->ifa_dev = in_dev; 541 ifa->ifa_dev = in_dev;
542 542
543 ifa->ifa_local = nla_get_u32(tb[IFA_LOCAL]); 543 ifa->ifa_local = nla_get_be32(tb[IFA_LOCAL]);
544 ifa->ifa_address = nla_get_u32(tb[IFA_ADDRESS]); 544 ifa->ifa_address = nla_get_be32(tb[IFA_ADDRESS]);
545 545
546 if (tb[IFA_BROADCAST]) 546 if (tb[IFA_BROADCAST])
547 ifa->ifa_broadcast = nla_get_u32(tb[IFA_BROADCAST]); 547 ifa->ifa_broadcast = nla_get_be32(tb[IFA_BROADCAST]);
548 548
549 if (tb[IFA_ANYCAST]) 549 if (tb[IFA_ANYCAST])
550 ifa->ifa_anycast = nla_get_u32(tb[IFA_ANYCAST]); 550 ifa->ifa_anycast = nla_get_be32(tb[IFA_ANYCAST]);
551 551
552 if (tb[IFA_LABEL]) 552 if (tb[IFA_LABEL])
553 nla_strlcpy(ifa->ifa_label, tb[IFA_LABEL], IFNAMSIZ); 553 nla_strlcpy(ifa->ifa_label, tb[IFA_LABEL], IFNAMSIZ);
@@ -805,7 +805,7 @@ int devinet_ioctl(unsigned int cmd, void __user *arg)
805 break; 805 break;
806 ret = 0; 806 ret = 0;
807 if (ifa->ifa_mask != sin->sin_addr.s_addr) { 807 if (ifa->ifa_mask != sin->sin_addr.s_addr) {
808 u32 old_mask = ifa->ifa_mask; 808 __be32 old_mask = ifa->ifa_mask;
809 inet_del_ifa(in_dev, ifap, 0); 809 inet_del_ifa(in_dev, ifap, 0);
810 ifa->ifa_mask = sin->sin_addr.s_addr; 810 ifa->ifa_mask = sin->sin_addr.s_addr;
811 ifa->ifa_prefixlen = inet_mask_len(ifa->ifa_mask); 811 ifa->ifa_prefixlen = inet_mask_len(ifa->ifa_mask);
@@ -876,9 +876,9 @@ out:
876 return done; 876 return done;
877} 877}
878 878
879u32 inet_select_addr(const struct net_device *dev, u32 dst, int scope) 879__be32 inet_select_addr(const struct net_device *dev, __be32 dst, int scope)
880{ 880{
881 u32 addr = 0; 881 __be32 addr = 0;
882 struct in_device *in_dev; 882 struct in_device *in_dev;
883 883
884 rcu_read_lock(); 884 rcu_read_lock();
@@ -927,11 +927,11 @@ out:
927 return addr; 927 return addr;
928} 928}
929 929
930static u32 confirm_addr_indev(struct in_device *in_dev, u32 dst, 930static __be32 confirm_addr_indev(struct in_device *in_dev, __be32 dst,
931 u32 local, int scope) 931 __be32 local, int scope)
932{ 932{
933 int same = 0; 933 int same = 0;
934 u32 addr = 0; 934 __be32 addr = 0;
935 935
936 for_ifa(in_dev) { 936 for_ifa(in_dev) {
937 if (!addr && 937 if (!addr &&
@@ -971,9 +971,9 @@ static u32 confirm_addr_indev(struct in_device *in_dev, u32 dst,
971 * - local: address, 0=autoselect the local address 971 * - local: address, 0=autoselect the local address
972 * - scope: maximum allowed scope value for the local address 972 * - scope: maximum allowed scope value for the local address
973 */ 973 */
974u32 inet_confirm_addr(const struct net_device *dev, u32 dst, u32 local, int scope) 974__be32 inet_confirm_addr(const struct net_device *dev, __be32 dst, __be32 local, int scope)
975{ 975{
976 u32 addr = 0; 976 __be32 addr = 0;
977 struct in_device *in_dev; 977 struct in_device *in_dev;
978 978
979 if (dev) { 979 if (dev) {
@@ -1138,16 +1138,16 @@ static int inet_fill_ifaddr(struct sk_buff *skb, struct in_ifaddr *ifa,
1138 ifm->ifa_index = ifa->ifa_dev->dev->ifindex; 1138 ifm->ifa_index = ifa->ifa_dev->dev->ifindex;
1139 1139
1140 if (ifa->ifa_address) 1140 if (ifa->ifa_address)
1141 NLA_PUT_U32(skb, IFA_ADDRESS, ifa->ifa_address); 1141 NLA_PUT_BE32(skb, IFA_ADDRESS, ifa->ifa_address);
1142 1142
1143 if (ifa->ifa_local) 1143 if (ifa->ifa_local)
1144 NLA_PUT_U32(skb, IFA_LOCAL, ifa->ifa_local); 1144 NLA_PUT_BE32(skb, IFA_LOCAL, ifa->ifa_local);
1145 1145
1146 if (ifa->ifa_broadcast) 1146 if (ifa->ifa_broadcast)
1147 NLA_PUT_U32(skb, IFA_BROADCAST, ifa->ifa_broadcast); 1147 NLA_PUT_BE32(skb, IFA_BROADCAST, ifa->ifa_broadcast);
1148 1148
1149 if (ifa->ifa_anycast) 1149 if (ifa->ifa_anycast)
1150 NLA_PUT_U32(skb, IFA_ANYCAST, ifa->ifa_anycast); 1150 NLA_PUT_BE32(skb, IFA_ANYCAST, ifa->ifa_anycast);
1151 1151
1152 if (ifa->ifa_label[0]) 1152 if (ifa->ifa_label[0])
1153 NLA_PUT_STRING(skb, IFA_LABEL, ifa->ifa_label); 1153 NLA_PUT_STRING(skb, IFA_LABEL, ifa->ifa_label);
diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
index cfb527c060e4..9c399a70dd5d 100644
--- a/net/ipv4/fib_frontend.c
+++ b/net/ipv4/fib_frontend.c
@@ -122,7 +122,7 @@ static void fib_flush(void)
122 * Find the first device with a given source address. 122 * Find the first device with a given source address.
123 */ 123 */
124 124
125struct net_device * ip_dev_find(u32 addr) 125struct net_device * ip_dev_find(__be32 addr)
126{ 126{
127 struct flowi fl = { .nl_u = { .ip4_u = { .daddr = addr } } }; 127 struct flowi fl = { .nl_u = { .ip4_u = { .daddr = addr } } };
128 struct fib_result res; 128 struct fib_result res;
@@ -146,7 +146,7 @@ out:
146 return dev; 146 return dev;
147} 147}
148 148
149unsigned inet_addr_type(u32 addr) 149unsigned inet_addr_type(__be32 addr)
150{ 150{
151 struct flowi fl = { .nl_u = { .ip4_u = { .daddr = addr } } }; 151 struct flowi fl = { .nl_u = { .ip4_u = { .daddr = addr } } };
152 struct fib_result res; 152 struct fib_result res;
@@ -180,8 +180,8 @@ unsigned inet_addr_type(u32 addr)
180 - check, that packet arrived from expected physical interface. 180 - check, that packet arrived from expected physical interface.
181 */ 181 */
182 182
183int fib_validate_source(u32 src, u32 dst, u8 tos, int oif, 183int fib_validate_source(__be32 src, __be32 dst, u8 tos, int oif,
184 struct net_device *dev, u32 *spec_dst, u32 *itag) 184 struct net_device *dev, __be32 *spec_dst, u32 *itag)
185{ 185{
186 struct in_device *in_dev; 186 struct in_device *in_dev;
187 struct flowi fl = { .nl_u = { .ip4_u = 187 struct flowi fl = { .nl_u = { .ip4_u =
@@ -253,7 +253,7 @@ e_inval:
253 253
254#ifndef CONFIG_IP_NOSIOCRT 254#ifndef CONFIG_IP_NOSIOCRT
255 255
256static inline u32 sk_extract_addr(struct sockaddr *addr) 256static inline __be32 sk_extract_addr(struct sockaddr *addr)
257{ 257{
258 return ((struct sockaddr_in *) addr)->sin_addr.s_addr; 258 return ((struct sockaddr_in *) addr)->sin_addr.s_addr;
259} 259}
@@ -273,7 +273,7 @@ static int put_rtax(struct nlattr *mx, int len, int type, u32 value)
273static int rtentry_to_fib_config(int cmd, struct rtentry *rt, 273static int rtentry_to_fib_config(int cmd, struct rtentry *rt,
274 struct fib_config *cfg) 274 struct fib_config *cfg)
275{ 275{
276 u32 addr; 276 __be32 addr;
277 int plen; 277 int plen;
278 278
279 memset(cfg, 0, sizeof(*cfg)); 279 memset(cfg, 0, sizeof(*cfg));
@@ -292,7 +292,7 @@ static int rtentry_to_fib_config(int cmd, struct rtentry *rt,
292 plen = 32; 292 plen = 32;
293 addr = sk_extract_addr(&rt->rt_dst); 293 addr = sk_extract_addr(&rt->rt_dst);
294 if (!(rt->rt_flags & RTF_HOST)) { 294 if (!(rt->rt_flags & RTF_HOST)) {
295 u32 mask = sk_extract_addr(&rt->rt_genmask); 295 __be32 mask = sk_extract_addr(&rt->rt_genmask);
296 296
297 if (rt->rt_genmask.sa_family != AF_INET) { 297 if (rt->rt_genmask.sa_family != AF_INET) {
298 if (mask || rt->rt_genmask.sa_family) 298 if (mask || rt->rt_genmask.sa_family)
@@ -499,22 +499,22 @@ static int rtm_to_fib_config(struct sk_buff *skb, struct nlmsghdr *nlh,
499 nlmsg_for_each_attr(attr, nlh, sizeof(struct rtmsg), remaining) { 499 nlmsg_for_each_attr(attr, nlh, sizeof(struct rtmsg), remaining) {
500 switch (attr->nla_type) { 500 switch (attr->nla_type) {
501 case RTA_DST: 501 case RTA_DST:
502 cfg->fc_dst = nla_get_u32(attr); 502 cfg->fc_dst = nla_get_be32(attr);
503 break; 503 break;
504 case RTA_SRC: 504 case RTA_SRC:
505 cfg->fc_src = nla_get_u32(attr); 505 cfg->fc_src = nla_get_be32(attr);
506 break; 506 break;
507 case RTA_OIF: 507 case RTA_OIF:
508 cfg->fc_oif = nla_get_u32(attr); 508 cfg->fc_oif = nla_get_u32(attr);
509 break; 509 break;
510 case RTA_GATEWAY: 510 case RTA_GATEWAY:
511 cfg->fc_gw = nla_get_u32(attr); 511 cfg->fc_gw = nla_get_be32(attr);
512 break; 512 break;
513 case RTA_PRIORITY: 513 case RTA_PRIORITY:
514 cfg->fc_priority = nla_get_u32(attr); 514 cfg->fc_priority = nla_get_u32(attr);
515 break; 515 break;
516 case RTA_PREFSRC: 516 case RTA_PREFSRC:
517 cfg->fc_prefsrc = nla_get_u32(attr); 517 cfg->fc_prefsrc = nla_get_be32(attr);
518 break; 518 break;
519 case RTA_METRICS: 519 case RTA_METRICS:
520 cfg->fc_mx = nla_data(attr); 520 cfg->fc_mx = nla_data(attr);
@@ -627,8 +627,7 @@ out:
627 only when netlink is already locked. 627 only when netlink is already locked.
628 */ 628 */
629 629
630static void fib_magic(int cmd, int type, u32 dst, int dst_len, 630static void fib_magic(int cmd, int type, __be32 dst, int dst_len, struct in_ifaddr *ifa)
631 struct in_ifaddr *ifa)
632{ 631{
633 struct fib_table *tb; 632 struct fib_table *tb;
634 struct fib_config cfg = { 633 struct fib_config cfg = {
@@ -667,9 +666,9 @@ void fib_add_ifaddr(struct in_ifaddr *ifa)
667 struct in_device *in_dev = ifa->ifa_dev; 666 struct in_device *in_dev = ifa->ifa_dev;
668 struct net_device *dev = in_dev->dev; 667 struct net_device *dev = in_dev->dev;
669 struct in_ifaddr *prim = ifa; 668 struct in_ifaddr *prim = ifa;
670 u32 mask = ifa->ifa_mask; 669 __be32 mask = ifa->ifa_mask;
671 u32 addr = ifa->ifa_local; 670 __be32 addr = ifa->ifa_local;
672 u32 prefix = ifa->ifa_address&mask; 671 __be32 prefix = ifa->ifa_address&mask;
673 672
674 if (ifa->ifa_flags&IFA_F_SECONDARY) { 673 if (ifa->ifa_flags&IFA_F_SECONDARY) {
675 prim = inet_ifa_byprefix(in_dev, prefix, mask); 674 prim = inet_ifa_byprefix(in_dev, prefix, mask);
@@ -685,7 +684,7 @@ void fib_add_ifaddr(struct in_ifaddr *ifa)
685 return; 684 return;
686 685
687 /* Add broadcast address, if it is explicitly assigned. */ 686 /* Add broadcast address, if it is explicitly assigned. */
688 if (ifa->ifa_broadcast && ifa->ifa_broadcast != 0xFFFFFFFF) 687 if (ifa->ifa_broadcast && ifa->ifa_broadcast != htonl(0xFFFFFFFF))
689 fib_magic(RTM_NEWROUTE, RTN_BROADCAST, ifa->ifa_broadcast, 32, prim); 688 fib_magic(RTM_NEWROUTE, RTN_BROADCAST, ifa->ifa_broadcast, 32, prim);
690 689
691 if (!ZERONET(prefix) && !(ifa->ifa_flags&IFA_F_SECONDARY) && 690 if (!ZERONET(prefix) && !(ifa->ifa_flags&IFA_F_SECONDARY) &&
@@ -707,8 +706,8 @@ static void fib_del_ifaddr(struct in_ifaddr *ifa)
707 struct net_device *dev = in_dev->dev; 706 struct net_device *dev = in_dev->dev;
708 struct in_ifaddr *ifa1; 707 struct in_ifaddr *ifa1;
709 struct in_ifaddr *prim = ifa; 708 struct in_ifaddr *prim = ifa;
710 u32 brd = ifa->ifa_address|~ifa->ifa_mask; 709 __be32 brd = ifa->ifa_address|~ifa->ifa_mask;
711 u32 any = ifa->ifa_address&ifa->ifa_mask; 710 __be32 any = ifa->ifa_address&ifa->ifa_mask;
712#define LOCAL_OK 1 711#define LOCAL_OK 1
713#define BRD_OK 2 712#define BRD_OK 2
714#define BRD0_OK 4 713#define BRD0_OK 4
diff --git a/net/ipv4/fib_hash.c b/net/ipv4/fib_hash.c
index 88133b383dc5..107bb6cbb0b3 100644
--- a/net/ipv4/fib_hash.c
+++ b/net/ipv4/fib_hash.c
@@ -51,7 +51,7 @@ static kmem_cache_t *fn_alias_kmem __read_mostly;
51struct fib_node { 51struct fib_node {
52 struct hlist_node fn_hash; 52 struct hlist_node fn_hash;
53 struct list_head fn_alias; 53 struct list_head fn_alias;
54 u32 fn_key; 54 __be32 fn_key;
55}; 55};
56 56
57struct fn_zone { 57struct fn_zone {
@@ -64,7 +64,7 @@ struct fn_zone {
64#define FZ_HASHMASK(fz) ((fz)->fz_hashmask) 64#define FZ_HASHMASK(fz) ((fz)->fz_hashmask)
65 65
66 int fz_order; /* Zone order */ 66 int fz_order; /* Zone order */
67 u32 fz_mask; 67 __be32 fz_mask;
68#define FZ_MASK(fz) ((fz)->fz_mask) 68#define FZ_MASK(fz) ((fz)->fz_mask)
69}; 69};
70 70
@@ -77,7 +77,7 @@ struct fn_hash {
77 struct fn_zone *fn_zone_list; 77 struct fn_zone *fn_zone_list;
78}; 78};
79 79
80static inline u32 fn_hash(u32 key, struct fn_zone *fz) 80static inline u32 fn_hash(__be32 key, struct fn_zone *fz)
81{ 81{
82 u32 h = ntohl(key)>>(32 - fz->fz_order); 82 u32 h = ntohl(key)>>(32 - fz->fz_order);
83 h ^= (h>>20); 83 h ^= (h>>20);
@@ -87,7 +87,7 @@ static inline u32 fn_hash(u32 key, struct fn_zone *fz)
87 return h; 87 return h;
88} 88}
89 89
90static inline u32 fz_key(u32 dst, struct fn_zone *fz) 90static inline __be32 fz_key(__be32 dst, struct fn_zone *fz)
91{ 91{
92 return dst & FZ_MASK(fz); 92 return dst & FZ_MASK(fz);
93} 93}
@@ -254,7 +254,7 @@ fn_hash_lookup(struct fib_table *tb, const struct flowi *flp, struct fib_result
254 struct hlist_head *head; 254 struct hlist_head *head;
255 struct hlist_node *node; 255 struct hlist_node *node;
256 struct fib_node *f; 256 struct fib_node *f;
257 u32 k = fz_key(flp->fl4_dst, fz); 257 __be32 k = fz_key(flp->fl4_dst, fz);
258 258
259 head = &fz->fz_hash[fn_hash(k, fz)]; 259 head = &fz->fz_hash[fn_hash(k, fz)];
260 hlist_for_each_entry(f, node, head, fn_hash) { 260 hlist_for_each_entry(f, node, head, fn_hash) {
@@ -365,7 +365,7 @@ static inline void fib_insert_node(struct fn_zone *fz, struct fib_node *f)
365} 365}
366 366
367/* Return the node in FZ matching KEY. */ 367/* Return the node in FZ matching KEY. */
368static struct fib_node *fib_find_node(struct fn_zone *fz, u32 key) 368static struct fib_node *fib_find_node(struct fn_zone *fz, __be32 key)
369{ 369{
370 struct hlist_head *head = &fz->fz_hash[fn_hash(key, fz)]; 370 struct hlist_head *head = &fz->fz_hash[fn_hash(key, fz)];
371 struct hlist_node *node; 371 struct hlist_node *node;
@@ -387,7 +387,7 @@ static int fn_hash_insert(struct fib_table *tb, struct fib_config *cfg)
387 struct fn_zone *fz; 387 struct fn_zone *fz;
388 struct fib_info *fi; 388 struct fib_info *fi;
389 u8 tos = cfg->fc_tos; 389 u8 tos = cfg->fc_tos;
390 u32 key; 390 __be32 key;
391 int err; 391 int err;
392 392
393 if (cfg->fc_dst_len > 32) 393 if (cfg->fc_dst_len > 32)
@@ -541,7 +541,7 @@ static int fn_hash_delete(struct fib_table *tb, struct fib_config *cfg)
541 struct fib_node *f; 541 struct fib_node *f;
542 struct fib_alias *fa, *fa_to_delete; 542 struct fib_alias *fa, *fa_to_delete;
543 struct fn_zone *fz; 543 struct fn_zone *fz;
544 u32 key; 544 __be32 key;
545 545
546 if (cfg->fc_dst_len > 32) 546 if (cfg->fc_dst_len > 32)
547 return -EINVAL; 547 return -EINVAL;
@@ -966,7 +966,7 @@ static void fib_seq_stop(struct seq_file *seq, void *v)
966 read_unlock(&fib_hash_lock); 966 read_unlock(&fib_hash_lock);
967} 967}
968 968
969static unsigned fib_flag_trans(int type, u32 mask, struct fib_info *fi) 969static unsigned fib_flag_trans(int type, __be32 mask, struct fib_info *fi)
970{ 970{
971 static const unsigned type2flags[RTN_MAX + 1] = { 971 static const unsigned type2flags[RTN_MAX + 1] = {
972 [7] = RTF_REJECT, [8] = RTF_REJECT, 972 [7] = RTF_REJECT, [8] = RTF_REJECT,
@@ -975,7 +975,7 @@ static unsigned fib_flag_trans(int type, u32 mask, struct fib_info *fi)
975 975
976 if (fi && fi->fib_nh->nh_gw) 976 if (fi && fi->fib_nh->nh_gw)
977 flags |= RTF_GATEWAY; 977 flags |= RTF_GATEWAY;
978 if (mask == 0xFFFFFFFF) 978 if (mask == htonl(0xFFFFFFFF))
979 flags |= RTF_HOST; 979 flags |= RTF_HOST;
980 flags |= RTF_UP; 980 flags |= RTF_UP;
981 return flags; 981 return flags;
@@ -991,7 +991,7 @@ static int fib_seq_show(struct seq_file *seq, void *v)
991{ 991{
992 struct fib_iter_state *iter; 992 struct fib_iter_state *iter;
993 char bf[128]; 993 char bf[128];
994 u32 prefix, mask; 994 __be32 prefix, mask;
995 unsigned flags; 995 unsigned flags;
996 struct fib_node *f; 996 struct fib_node *f;
997 struct fib_alias *fa; 997 struct fib_alias *fa;
diff --git a/net/ipv4/fib_lookup.h b/net/ipv4/fib_lookup.h
index fd6f7769f8ab..0e8b70bad4e1 100644
--- a/net/ipv4/fib_lookup.h
+++ b/net/ipv4/fib_lookup.h
@@ -20,16 +20,16 @@ struct fib_alias {
20/* Exported by fib_semantics.c */ 20/* Exported by fib_semantics.c */
21extern int fib_semantic_match(struct list_head *head, 21extern int fib_semantic_match(struct list_head *head,
22 const struct flowi *flp, 22 const struct flowi *flp,
23 struct fib_result *res, __u32 zone, __u32 mask, 23 struct fib_result *res, __be32 zone, __be32 mask,
24 int prefixlen); 24 int prefixlen);
25extern void fib_release_info(struct fib_info *); 25extern void fib_release_info(struct fib_info *);
26extern struct fib_info *fib_create_info(struct fib_config *cfg); 26extern struct fib_info *fib_create_info(struct fib_config *cfg);
27extern int fib_nh_match(struct fib_config *cfg, struct fib_info *fi); 27extern int fib_nh_match(struct fib_config *cfg, struct fib_info *fi);
28extern int fib_dump_info(struct sk_buff *skb, u32 pid, u32 seq, int event, 28extern int fib_dump_info(struct sk_buff *skb, u32 pid, u32 seq, int event,
29 u32 tb_id, u8 type, u8 scope, u32 dst, 29 u32 tb_id, u8 type, u8 scope, __be32 dst,
30 int dst_len, u8 tos, struct fib_info *fi, 30 int dst_len, u8 tos, struct fib_info *fi,
31 unsigned int); 31 unsigned int);
32extern void rtmsg_fib(int event, u32 key, struct fib_alias *fa, 32extern void rtmsg_fib(int event, __be32 key, struct fib_alias *fa,
33 int dst_len, u32 tb_id, struct nl_info *info); 33 int dst_len, u32 tb_id, struct nl_info *info);
34extern struct fib_alias *fib_find_alias(struct list_head *fah, 34extern struct fib_alias *fib_find_alias(struct list_head *fah,
35 u8 tos, u32 prio); 35 u8 tos, u32 prio);
diff --git a/net/ipv4/fib_rules.c b/net/ipv4/fib_rules.c
index 52b2adae4f22..0852b9cd065a 100644
--- a/net/ipv4/fib_rules.c
+++ b/net/ipv4/fib_rules.c
@@ -40,10 +40,10 @@ struct fib4_rule
40 u8 dst_len; 40 u8 dst_len;
41 u8 src_len; 41 u8 src_len;
42 u8 tos; 42 u8 tos;
43 u32 src; 43 __be32 src;
44 u32 srcmask; 44 __be32 srcmask;
45 u32 dst; 45 __be32 dst;
46 u32 dstmask; 46 __be32 dstmask;
47#ifdef CONFIG_IP_ROUTE_FWMARK 47#ifdef CONFIG_IP_ROUTE_FWMARK
48 u32 fwmark; 48 u32 fwmark;
49 u32 fwmask; 49 u32 fwmask;
@@ -150,8 +150,8 @@ void fib_select_default(const struct flowi *flp, struct fib_result *res)
150static int fib4_rule_match(struct fib_rule *rule, struct flowi *fl, int flags) 150static int fib4_rule_match(struct fib_rule *rule, struct flowi *fl, int flags)
151{ 151{
152 struct fib4_rule *r = (struct fib4_rule *) rule; 152 struct fib4_rule *r = (struct fib4_rule *) rule;
153 u32 daddr = fl->fl4_dst; 153 __be32 daddr = fl->fl4_dst;
154 u32 saddr = fl->fl4_src; 154 __be32 saddr = fl->fl4_src;
155 155
156 if (((saddr ^ r->src) & r->srcmask) || 156 if (((saddr ^ r->src) & r->srcmask) ||
157 ((daddr ^ r->dst) & r->dstmask)) 157 ((daddr ^ r->dst) & r->dstmask))
@@ -215,10 +215,10 @@ static int fib4_rule_configure(struct fib_rule *rule, struct sk_buff *skb,
215 } 215 }
216 216
217 if (tb[FRA_SRC]) 217 if (tb[FRA_SRC])
218 rule4->src = nla_get_u32(tb[FRA_SRC]); 218 rule4->src = nla_get_be32(tb[FRA_SRC]);
219 219
220 if (tb[FRA_DST]) 220 if (tb[FRA_DST])
221 rule4->dst = nla_get_u32(tb[FRA_DST]); 221 rule4->dst = nla_get_be32(tb[FRA_DST]);
222 222
223#ifdef CONFIG_IP_ROUTE_FWMARK 223#ifdef CONFIG_IP_ROUTE_FWMARK
224 if (tb[FRA_FWMARK]) { 224 if (tb[FRA_FWMARK]) {
@@ -277,10 +277,10 @@ static int fib4_rule_compare(struct fib_rule *rule, struct fib_rule_hdr *frh,
277 return 0; 277 return 0;
278#endif 278#endif
279 279
280 if (tb[FRA_SRC] && (rule4->src != nla_get_u32(tb[FRA_SRC]))) 280 if (tb[FRA_SRC] && (rule4->src != nla_get_be32(tb[FRA_SRC])))
281 return 0; 281 return 0;
282 282
283 if (tb[FRA_DST] && (rule4->dst != nla_get_u32(tb[FRA_DST]))) 283 if (tb[FRA_DST] && (rule4->dst != nla_get_be32(tb[FRA_DST])))
284 return 0; 284 return 0;
285 285
286 return 1; 286 return 1;
@@ -305,10 +305,10 @@ static int fib4_rule_fill(struct fib_rule *rule, struct sk_buff *skb,
305#endif 305#endif
306 306
307 if (rule4->dst_len) 307 if (rule4->dst_len)
308 NLA_PUT_U32(skb, FRA_DST, rule4->dst); 308 NLA_PUT_BE32(skb, FRA_DST, rule4->dst);
309 309
310 if (rule4->src_len) 310 if (rule4->src_len)
311 NLA_PUT_U32(skb, FRA_SRC, rule4->src); 311 NLA_PUT_BE32(skb, FRA_SRC, rule4->src);
312 312
313#ifdef CONFIG_NET_CLS_ROUTE 313#ifdef CONFIG_NET_CLS_ROUTE
314 if (rule4->tclassid) 314 if (rule4->tclassid)
diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
index 2ead09543f68..884d176e0082 100644
--- a/net/ipv4/fib_semantics.c
+++ b/net/ipv4/fib_semantics.c
@@ -203,7 +203,7 @@ static inline unsigned int fib_info_hashfn(const struct fib_info *fi)
203 unsigned int val = fi->fib_nhs; 203 unsigned int val = fi->fib_nhs;
204 204
205 val ^= fi->fib_protocol; 205 val ^= fi->fib_protocol;
206 val ^= fi->fib_prefsrc; 206 val ^= (__force u32)fi->fib_prefsrc;
207 val ^= fi->fib_priority; 207 val ^= fi->fib_priority;
208 208
209 return (val ^ (val >> 7) ^ (val >> 12)) & mask; 209 return (val ^ (val >> 7) ^ (val >> 12)) & mask;
@@ -248,7 +248,7 @@ static inline unsigned int fib_devindex_hashfn(unsigned int val)
248 Used only by redirect accept routine. 248 Used only by redirect accept routine.
249 */ 249 */
250 250
251int ip_fib_check_default(u32 gw, struct net_device *dev) 251int ip_fib_check_default(__be32 gw, struct net_device *dev)
252{ 252{
253 struct hlist_head *head; 253 struct hlist_head *head;
254 struct hlist_node *node; 254 struct hlist_node *node;
@@ -273,7 +273,7 @@ int ip_fib_check_default(u32 gw, struct net_device *dev)
273 return -1; 273 return -1;
274} 274}
275 275
276void rtmsg_fib(int event, u32 key, struct fib_alias *fa, 276void rtmsg_fib(int event, __be32 key, struct fib_alias *fa,
277 int dst_len, u32 tb_id, struct nl_info *info) 277 int dst_len, u32 tb_id, struct nl_info *info)
278{ 278{
279 struct sk_buff *skb; 279 struct sk_buff *skb;
@@ -374,7 +374,7 @@ static int fib_get_nhs(struct fib_info *fi, struct rtnexthop *rtnh,
374 struct nlattr *nla, *attrs = rtnh_attrs(rtnh); 374 struct nlattr *nla, *attrs = rtnh_attrs(rtnh);
375 375
376 nla = nla_find(attrs, attrlen, RTA_GATEWAY); 376 nla = nla_find(attrs, attrlen, RTA_GATEWAY);
377 nh->nh_gw = nla ? nla_get_u32(nla) : 0; 377 nh->nh_gw = nla ? nla_get_be32(nla) : 0;
378#ifdef CONFIG_NET_CLS_ROUTE 378#ifdef CONFIG_NET_CLS_ROUTE
379 nla = nla_find(attrs, attrlen, RTA_FLOW); 379 nla = nla_find(attrs, attrlen, RTA_FLOW);
380 nh->nh_tclassid = nla ? nla_get_u32(nla) : 0; 380 nh->nh_tclassid = nla ? nla_get_u32(nla) : 0;
@@ -427,7 +427,7 @@ int fib_nh_match(struct fib_config *cfg, struct fib_info *fi)
427 struct nlattr *nla, *attrs = rtnh_attrs(rtnh); 427 struct nlattr *nla, *attrs = rtnh_attrs(rtnh);
428 428
429 nla = nla_find(attrs, attrlen, RTA_GATEWAY); 429 nla = nla_find(attrs, attrlen, RTA_GATEWAY);
430 if (nla && nla_get_u32(nla) != nh->nh_gw) 430 if (nla && nla_get_be32(nla) != nh->nh_gw)
431 return 1; 431 return 1;
432#ifdef CONFIG_NET_CLS_ROUTE 432#ifdef CONFIG_NET_CLS_ROUTE
433 nla = nla_find(attrs, attrlen, RTA_FLOW); 433 nla = nla_find(attrs, attrlen, RTA_FLOW);
@@ -568,11 +568,11 @@ out:
568 return 0; 568 return 0;
569} 569}
570 570
571static inline unsigned int fib_laddr_hashfn(u32 val) 571static inline unsigned int fib_laddr_hashfn(__be32 val)
572{ 572{
573 unsigned int mask = (fib_hash_size - 1); 573 unsigned int mask = (fib_hash_size - 1);
574 574
575 return (val ^ (val >> 7) ^ (val >> 14)) & mask; 575 return ((__force u32)val ^ ((__force u32)val >> 7) ^ ((__force u32)val >> 14)) & mask;
576} 576}
577 577
578static struct hlist_head *fib_hash_alloc(int bytes) 578static struct hlist_head *fib_hash_alloc(int bytes)
@@ -847,7 +847,7 @@ failure:
847 847
848/* Note! fib_semantic_match intentionally uses RCU list functions. */ 848/* Note! fib_semantic_match intentionally uses RCU list functions. */
849int fib_semantic_match(struct list_head *head, const struct flowi *flp, 849int fib_semantic_match(struct list_head *head, const struct flowi *flp,
850 struct fib_result *res, __u32 zone, __u32 mask, 850 struct fib_result *res, __be32 zone, __be32 mask,
851 int prefixlen) 851 int prefixlen)
852{ 852{
853 struct fib_alias *fa; 853 struct fib_alias *fa;
@@ -914,8 +914,7 @@ out_fill_res:
914 res->fi = fa->fa_info; 914 res->fi = fa->fa_info;
915#ifdef CONFIG_IP_ROUTE_MULTIPATH_CACHED 915#ifdef CONFIG_IP_ROUTE_MULTIPATH_CACHED
916 res->netmask = mask; 916 res->netmask = mask;
917 res->network = zone & 917 res->network = zone & inet_make_mask(prefixlen);
918 (0xFFFFFFFF >> (32 - prefixlen));
919#endif 918#endif
920 atomic_inc(&res->fi->fib_clntref); 919 atomic_inc(&res->fi->fib_clntref);
921 return 0; 920 return 0;
@@ -923,13 +922,13 @@ out_fill_res:
923 922
924/* Find appropriate source address to this destination */ 923/* Find appropriate source address to this destination */
925 924
926u32 __fib_res_prefsrc(struct fib_result *res) 925__be32 __fib_res_prefsrc(struct fib_result *res)
927{ 926{
928 return inet_select_addr(FIB_RES_DEV(*res), FIB_RES_GW(*res), res->scope); 927 return inet_select_addr(FIB_RES_DEV(*res), FIB_RES_GW(*res), res->scope);
929} 928}
930 929
931int fib_dump_info(struct sk_buff *skb, u32 pid, u32 seq, int event, 930int fib_dump_info(struct sk_buff *skb, u32 pid, u32 seq, int event,
932 u32 tb_id, u8 type, u8 scope, u32 dst, int dst_len, u8 tos, 931 u32 tb_id, u8 type, u8 scope, __be32 dst, int dst_len, u8 tos,
933 struct fib_info *fi, unsigned int flags) 932 struct fib_info *fi, unsigned int flags)
934{ 933{
935 struct nlmsghdr *nlh; 934 struct nlmsghdr *nlh;
@@ -952,7 +951,7 @@ int fib_dump_info(struct sk_buff *skb, u32 pid, u32 seq, int event,
952 rtm->rtm_protocol = fi->fib_protocol; 951 rtm->rtm_protocol = fi->fib_protocol;
953 952
954 if (rtm->rtm_dst_len) 953 if (rtm->rtm_dst_len)
955 NLA_PUT_U32(skb, RTA_DST, dst); 954 NLA_PUT_BE32(skb, RTA_DST, dst);
956 955
957 if (fi->fib_priority) 956 if (fi->fib_priority)
958 NLA_PUT_U32(skb, RTA_PRIORITY, fi->fib_priority); 957 NLA_PUT_U32(skb, RTA_PRIORITY, fi->fib_priority);
@@ -961,11 +960,11 @@ int fib_dump_info(struct sk_buff *skb, u32 pid, u32 seq, int event,
961 goto nla_put_failure; 960 goto nla_put_failure;
962 961
963 if (fi->fib_prefsrc) 962 if (fi->fib_prefsrc)
964 NLA_PUT_U32(skb, RTA_PREFSRC, fi->fib_prefsrc); 963 NLA_PUT_BE32(skb, RTA_PREFSRC, fi->fib_prefsrc);
965 964
966 if (fi->fib_nhs == 1) { 965 if (fi->fib_nhs == 1) {
967 if (fi->fib_nh->nh_gw) 966 if (fi->fib_nh->nh_gw)
968 NLA_PUT_U32(skb, RTA_GATEWAY, fi->fib_nh->nh_gw); 967 NLA_PUT_BE32(skb, RTA_GATEWAY, fi->fib_nh->nh_gw);
969 968
970 if (fi->fib_nh->nh_oif) 969 if (fi->fib_nh->nh_oif)
971 NLA_PUT_U32(skb, RTA_OIF, fi->fib_nh->nh_oif); 970 NLA_PUT_U32(skb, RTA_OIF, fi->fib_nh->nh_oif);
@@ -993,7 +992,7 @@ int fib_dump_info(struct sk_buff *skb, u32 pid, u32 seq, int event,
993 rtnh->rtnh_ifindex = nh->nh_oif; 992 rtnh->rtnh_ifindex = nh->nh_oif;
994 993
995 if (nh->nh_gw) 994 if (nh->nh_gw)
996 NLA_PUT_U32(skb, RTA_GATEWAY, nh->nh_gw); 995 NLA_PUT_BE32(skb, RTA_GATEWAY, nh->nh_gw);
997#ifdef CONFIG_NET_CLS_ROUTE 996#ifdef CONFIG_NET_CLS_ROUTE
998 if (nh->nh_tclassid) 997 if (nh->nh_tclassid)
999 NLA_PUT_U32(skb, RTA_FLOW, nh->nh_tclassid); 998 NLA_PUT_U32(skb, RTA_FLOW, nh->nh_tclassid);
@@ -1018,7 +1017,7 @@ nla_put_failure:
1018 - device went down -> we must shutdown all nexthops going via it. 1017 - device went down -> we must shutdown all nexthops going via it.
1019 */ 1018 */
1020 1019
1021int fib_sync_down(u32 local, struct net_device *dev, int force) 1020int fib_sync_down(__be32 local, struct net_device *dev, int force)
1022{ 1021{
1023 int ret = 0; 1022 int ret = 0;
1024 int scope = RT_SCOPE_NOWHERE; 1023 int scope = RT_SCOPE_NOWHERE;
diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c
index 9c3ff6ba6e21..d17990ec724f 100644
--- a/net/ipv4/fib_trie.c
+++ b/net/ipv4/fib_trie.c
@@ -1834,7 +1834,7 @@ static int fn_trie_dump_fa(t_key key, int plen, struct list_head *fah, struct fi
1834 int i, s_i; 1834 int i, s_i;
1835 struct fib_alias *fa; 1835 struct fib_alias *fa;
1836 1836
1837 u32 xkey = htonl(key); 1837 __be32 xkey = htonl(key);
1838 1838
1839 s_i = cb->args[4]; 1839 s_i = cb->args[4];
1840 i = 0; 1840 i = 0;
@@ -2281,7 +2281,7 @@ static int fib_trie_seq_show(struct seq_file *seq, void *v)
2281 2281
2282 if (IS_TNODE(n)) { 2282 if (IS_TNODE(n)) {
2283 struct tnode *tn = (struct tnode *) n; 2283 struct tnode *tn = (struct tnode *) n;
2284 t_key prf = ntohl(MASK_PFX(tn->key, tn->pos)); 2284 __be32 prf = htonl(MASK_PFX(tn->key, tn->pos));
2285 2285
2286 if (!NODE_PARENT(n)) { 2286 if (!NODE_PARENT(n)) {
2287 if (iter->trie == trie_local) 2287 if (iter->trie == trie_local)
@@ -2297,7 +2297,7 @@ static int fib_trie_seq_show(struct seq_file *seq, void *v)
2297 } else { 2297 } else {
2298 struct leaf *l = (struct leaf *) n; 2298 struct leaf *l = (struct leaf *) n;
2299 int i; 2299 int i;
2300 u32 val = ntohl(l->key); 2300 __be32 val = htonl(l->key);
2301 2301
2302 seq_indent(seq, iter->depth); 2302 seq_indent(seq, iter->depth);
2303 seq_printf(seq, " |-- %d.%d.%d.%d\n", NIPQUAD(val)); 2303 seq_printf(seq, " |-- %d.%d.%d.%d\n", NIPQUAD(val));
@@ -2360,7 +2360,7 @@ static struct file_operations fib_trie_fops = {
2360 .release = seq_release_private, 2360 .release = seq_release_private,
2361}; 2361};
2362 2362
2363static unsigned fib_flag_trans(int type, u32 mask, const struct fib_info *fi) 2363static unsigned fib_flag_trans(int type, __be32 mask, const struct fib_info *fi)
2364{ 2364{
2365 static unsigned type2flags[RTN_MAX + 1] = { 2365 static unsigned type2flags[RTN_MAX + 1] = {
2366 [7] = RTF_REJECT, [8] = RTF_REJECT, 2366 [7] = RTF_REJECT, [8] = RTF_REJECT,
@@ -2369,7 +2369,7 @@ static unsigned fib_flag_trans(int type, u32 mask, const struct fib_info *fi)
2369 2369
2370 if (fi && fi->fib_nh->nh_gw) 2370 if (fi && fi->fib_nh->nh_gw)
2371 flags |= RTF_GATEWAY; 2371 flags |= RTF_GATEWAY;
2372 if (mask == 0xFFFFFFFF) 2372 if (mask == htonl(0xFFFFFFFF))
2373 flags |= RTF_HOST; 2373 flags |= RTF_HOST;
2374 flags |= RTF_UP; 2374 flags |= RTF_UP;
2375 return flags; 2375 return flags;
@@ -2403,7 +2403,7 @@ static int fib_route_seq_show(struct seq_file *seq, void *v)
2403 for (i=32; i>=0; i--) { 2403 for (i=32; i>=0; i--) {
2404 struct leaf_info *li = find_leaf_info(l, i); 2404 struct leaf_info *li = find_leaf_info(l, i);
2405 struct fib_alias *fa; 2405 struct fib_alias *fa;
2406 u32 mask, prefix; 2406 __be32 mask, prefix;
2407 2407
2408 if (!li) 2408 if (!li)
2409 continue; 2409 continue;
diff --git a/net/ipv4/icmp.c b/net/ipv4/icmp.c
index c2ad07e48ab4..b39a37a47545 100644
--- a/net/ipv4/icmp.c
+++ b/net/ipv4/icmp.c
@@ -104,7 +104,7 @@ struct icmp_bxm {
104 104
105 struct { 105 struct {
106 struct icmphdr icmph; 106 struct icmphdr icmph;
107 __u32 times[3]; 107 __be32 times[3];
108 } data; 108 } data;
109 int head_len; 109 int head_len;
110 struct ip_options replyopts; 110 struct ip_options replyopts;
@@ -381,7 +381,7 @@ static void icmp_reply(struct icmp_bxm *icmp_param, struct sk_buff *skb)
381 struct inet_sock *inet = inet_sk(sk); 381 struct inet_sock *inet = inet_sk(sk);
382 struct ipcm_cookie ipc; 382 struct ipcm_cookie ipc;
383 struct rtable *rt = (struct rtable *)skb->dst; 383 struct rtable *rt = (struct rtable *)skb->dst;
384 u32 daddr; 384 __be32 daddr;
385 385
386 if (ip_options_echo(&icmp_param->replyopts, skb)) 386 if (ip_options_echo(&icmp_param->replyopts, skb))
387 return; 387 return;
@@ -430,14 +430,14 @@ out_unlock:
430 * MUST reply to only the first fragment. 430 * MUST reply to only the first fragment.
431 */ 431 */
432 432
433void icmp_send(struct sk_buff *skb_in, int type, int code, u32 info) 433void icmp_send(struct sk_buff *skb_in, int type, int code, __be32 info)
434{ 434{
435 struct iphdr *iph; 435 struct iphdr *iph;
436 int room; 436 int room;
437 struct icmp_bxm icmp_param; 437 struct icmp_bxm icmp_param;
438 struct rtable *rt = (struct rtable *)skb_in->dst; 438 struct rtable *rt = (struct rtable *)skb_in->dst;
439 struct ipcm_cookie ipc; 439 struct ipcm_cookie ipc;
440 u32 saddr; 440 __be32 saddr;
441 u8 tos; 441 u8 tos;
442 442
443 if (!rt) 443 if (!rt)
@@ -895,7 +895,7 @@ static void icmp_address_reply(struct sk_buff *skb)
895 if (in_dev->ifa_list && 895 if (in_dev->ifa_list &&
896 IN_DEV_LOG_MARTIANS(in_dev) && 896 IN_DEV_LOG_MARTIANS(in_dev) &&
897 IN_DEV_FORWARD(in_dev)) { 897 IN_DEV_FORWARD(in_dev)) {
898 u32 _mask, *mp; 898 __be32 _mask, *mp;
899 899
900 mp = skb_header_pointer(skb, 0, sizeof(_mask), &_mask); 900 mp = skb_header_pointer(skb, 0, sizeof(_mask), &_mask);
901 BUG_ON(mp == NULL); 901 BUG_ON(mp == NULL);
diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c
index 58be8227b0cb..6eee71647b7c 100644
--- a/net/ipv4/igmp.c
+++ b/net/ipv4/igmp.c
@@ -138,14 +138,14 @@
138 time_before(jiffies, (in_dev)->mr_v2_seen))) 138 time_before(jiffies, (in_dev)->mr_v2_seen)))
139 139
140static void igmpv3_add_delrec(struct in_device *in_dev, struct ip_mc_list *im); 140static void igmpv3_add_delrec(struct in_device *in_dev, struct ip_mc_list *im);
141static void igmpv3_del_delrec(struct in_device *in_dev, __u32 multiaddr); 141static void igmpv3_del_delrec(struct in_device *in_dev, __be32 multiaddr);
142static void igmpv3_clear_delrec(struct in_device *in_dev); 142static void igmpv3_clear_delrec(struct in_device *in_dev);
143static int sf_setstate(struct ip_mc_list *pmc); 143static int sf_setstate(struct ip_mc_list *pmc);
144static void sf_markstate(struct ip_mc_list *pmc); 144static void sf_markstate(struct ip_mc_list *pmc);
145#endif 145#endif
146static void ip_mc_clear_src(struct ip_mc_list *pmc); 146static void ip_mc_clear_src(struct ip_mc_list *pmc);
147static int ip_mc_add_src(struct in_device *in_dev, __u32 *pmca, int sfmode, 147static int ip_mc_add_src(struct in_device *in_dev, __be32 *pmca, int sfmode,
148 int sfcount, __u32 *psfsrc, int delta); 148 int sfcount, __be32 *psfsrc, int delta);
149 149
150static void ip_ma_put(struct ip_mc_list *im) 150static void ip_ma_put(struct ip_mc_list *im)
151{ 151{
@@ -426,7 +426,7 @@ static struct sk_buff *add_grec(struct sk_buff *skb, struct ip_mc_list *pmc,
426 first = 1; 426 first = 1;
427 psf_prev = NULL; 427 psf_prev = NULL;
428 for (psf=*psf_list; psf; psf=psf_next) { 428 for (psf=*psf_list; psf; psf=psf_next) {
429 u32 *psrc; 429 __be32 *psrc;
430 430
431 psf_next = psf->sf_next; 431 psf_next = psf->sf_next;
432 432
@@ -439,7 +439,7 @@ static struct sk_buff *add_grec(struct sk_buff *skb, struct ip_mc_list *pmc,
439 if (isquery) 439 if (isquery)
440 psf->sf_gsresp = 0; 440 psf->sf_gsresp = 0;
441 441
442 if (AVAILABLE(skb) < sizeof(u32) + 442 if (AVAILABLE(skb) < sizeof(__be32) +
443 first*sizeof(struct igmpv3_grec)) { 443 first*sizeof(struct igmpv3_grec)) {
444 if (truncate && !first) 444 if (truncate && !first)
445 break; /* truncate these */ 445 break; /* truncate these */
@@ -455,7 +455,7 @@ static struct sk_buff *add_grec(struct sk_buff *skb, struct ip_mc_list *pmc,
455 skb = add_grhead(skb, pmc, type, &pgr); 455 skb = add_grhead(skb, pmc, type, &pgr);
456 first = 0; 456 first = 0;
457 } 457 }
458 psrc = (u32 *)skb_put(skb, sizeof(u32)); 458 psrc = (__be32 *)skb_put(skb, sizeof(__be32));
459 *psrc = psf->sf_inaddr; 459 *psrc = psf->sf_inaddr;
460 scount++; stotal++; 460 scount++; stotal++;
461 if ((type == IGMPV3_ALLOW_NEW_SOURCES || 461 if ((type == IGMPV3_ALLOW_NEW_SOURCES ||
@@ -630,8 +630,8 @@ static int igmp_send_report(struct in_device *in_dev, struct ip_mc_list *pmc,
630 struct igmphdr *ih; 630 struct igmphdr *ih;
631 struct rtable *rt; 631 struct rtable *rt;
632 struct net_device *dev = in_dev->dev; 632 struct net_device *dev = in_dev->dev;
633 u32 group = pmc ? pmc->multiaddr : 0; 633 __be32 group = pmc ? pmc->multiaddr : 0;
634 u32 dst; 634 __be32 dst;
635 635
636 if (type == IGMPV3_HOST_MEMBERSHIP_REPORT) 636 if (type == IGMPV3_HOST_MEMBERSHIP_REPORT)
637 return igmpv3_send_report(in_dev, pmc); 637 return igmpv3_send_report(in_dev, pmc);
@@ -748,7 +748,7 @@ static void igmp_timer_expire(unsigned long data)
748} 748}
749 749
750/* mark EXCLUDE-mode sources */ 750/* mark EXCLUDE-mode sources */
751static int igmp_xmarksources(struct ip_mc_list *pmc, int nsrcs, __u32 *srcs) 751static int igmp_xmarksources(struct ip_mc_list *pmc, int nsrcs, __be32 *srcs)
752{ 752{
753 struct ip_sf_list *psf; 753 struct ip_sf_list *psf;
754 int i, scount; 754 int i, scount;
@@ -775,7 +775,7 @@ static int igmp_xmarksources(struct ip_mc_list *pmc, int nsrcs, __u32 *srcs)
775 return 1; 775 return 1;
776} 776}
777 777
778static int igmp_marksources(struct ip_mc_list *pmc, int nsrcs, __u32 *srcs) 778static int igmp_marksources(struct ip_mc_list *pmc, int nsrcs, __be32 *srcs)
779{ 779{
780 struct ip_sf_list *psf; 780 struct ip_sf_list *psf;
781 int i, scount; 781 int i, scount;
@@ -803,7 +803,7 @@ static int igmp_marksources(struct ip_mc_list *pmc, int nsrcs, __u32 *srcs)
803 return 1; 803 return 1;
804} 804}
805 805
806static void igmp_heard_report(struct in_device *in_dev, u32 group) 806static void igmp_heard_report(struct in_device *in_dev, __be32 group)
807{ 807{
808 struct ip_mc_list *im; 808 struct ip_mc_list *im;
809 809
@@ -828,7 +828,7 @@ static void igmp_heard_query(struct in_device *in_dev, struct sk_buff *skb,
828 struct igmphdr *ih = skb->h.igmph; 828 struct igmphdr *ih = skb->h.igmph;
829 struct igmpv3_query *ih3 = (struct igmpv3_query *)ih; 829 struct igmpv3_query *ih3 = (struct igmpv3_query *)ih;
830 struct ip_mc_list *im; 830 struct ip_mc_list *im;
831 u32 group = ih->group; 831 __be32 group = ih->group;
832 int max_delay; 832 int max_delay;
833 int mark = 0; 833 int mark = 0;
834 834
@@ -862,7 +862,7 @@ static void igmp_heard_query(struct in_device *in_dev, struct sk_buff *skb,
862 ih3 = (struct igmpv3_query *) skb->h.raw; 862 ih3 = (struct igmpv3_query *) skb->h.raw;
863 if (ih3->nsrcs) { 863 if (ih3->nsrcs) {
864 if (!pskb_may_pull(skb, sizeof(struct igmpv3_query) 864 if (!pskb_may_pull(skb, sizeof(struct igmpv3_query)
865 + ntohs(ih3->nsrcs)*sizeof(__u32))) 865 + ntohs(ih3->nsrcs)*sizeof(__be32)))
866 return; 866 return;
867 ih3 = (struct igmpv3_query *) skb->h.raw; 867 ih3 = (struct igmpv3_query *) skb->h.raw;
868 } 868 }
@@ -985,7 +985,7 @@ drop:
985 * Add a filter to a device 985 * Add a filter to a device
986 */ 986 */
987 987
988static void ip_mc_filter_add(struct in_device *in_dev, u32 addr) 988static void ip_mc_filter_add(struct in_device *in_dev, __be32 addr)
989{ 989{
990 char buf[MAX_ADDR_LEN]; 990 char buf[MAX_ADDR_LEN];
991 struct net_device *dev = in_dev->dev; 991 struct net_device *dev = in_dev->dev;
@@ -1005,7 +1005,7 @@ static void ip_mc_filter_add(struct in_device *in_dev, u32 addr)
1005 * Remove a filter from a device 1005 * Remove a filter from a device
1006 */ 1006 */
1007 1007
1008static void ip_mc_filter_del(struct in_device *in_dev, u32 addr) 1008static void ip_mc_filter_del(struct in_device *in_dev, __be32 addr)
1009{ 1009{
1010 char buf[MAX_ADDR_LEN]; 1010 char buf[MAX_ADDR_LEN];
1011 struct net_device *dev = in_dev->dev; 1011 struct net_device *dev = in_dev->dev;
@@ -1055,7 +1055,7 @@ static void igmpv3_add_delrec(struct in_device *in_dev, struct ip_mc_list *im)
1055 spin_unlock_bh(&in_dev->mc_tomb_lock); 1055 spin_unlock_bh(&in_dev->mc_tomb_lock);
1056} 1056}
1057 1057
1058static void igmpv3_del_delrec(struct in_device *in_dev, __u32 multiaddr) 1058static void igmpv3_del_delrec(struct in_device *in_dev, __be32 multiaddr)
1059{ 1059{
1060 struct ip_mc_list *pmc, *pmc_prev; 1060 struct ip_mc_list *pmc, *pmc_prev;
1061 struct ip_sf_list *psf, *psf_next; 1061 struct ip_sf_list *psf, *psf_next;
@@ -1193,7 +1193,7 @@ static void igmp_group_added(struct ip_mc_list *im)
1193 * A socket has joined a multicast group on device dev. 1193 * A socket has joined a multicast group on device dev.
1194 */ 1194 */
1195 1195
1196void ip_mc_inc_group(struct in_device *in_dev, u32 addr) 1196void ip_mc_inc_group(struct in_device *in_dev, __be32 addr)
1197{ 1197{
1198 struct ip_mc_list *im; 1198 struct ip_mc_list *im;
1199 1199
@@ -1252,7 +1252,7 @@ out:
1252 * A socket has left a multicast group on device dev 1252 * A socket has left a multicast group on device dev
1253 */ 1253 */
1254 1254
1255void ip_mc_dec_group(struct in_device *in_dev, u32 addr) 1255void ip_mc_dec_group(struct in_device *in_dev, __be32 addr)
1256{ 1256{
1257 struct ip_mc_list *i, **ip; 1257 struct ip_mc_list *i, **ip;
1258 1258
@@ -1402,7 +1402,7 @@ int sysctl_igmp_max_msf __read_mostly = IP_MAX_MSF;
1402 1402
1403 1403
1404static int ip_mc_del1_src(struct ip_mc_list *pmc, int sfmode, 1404static int ip_mc_del1_src(struct ip_mc_list *pmc, int sfmode,
1405 __u32 *psfsrc) 1405 __be32 *psfsrc)
1406{ 1406{
1407 struct ip_sf_list *psf, *psf_prev; 1407 struct ip_sf_list *psf, *psf_prev;
1408 int rv = 0; 1408 int rv = 0;
@@ -1450,8 +1450,8 @@ static int ip_mc_del1_src(struct ip_mc_list *pmc, int sfmode,
1450#define igmp_ifc_event(x) do { } while (0) 1450#define igmp_ifc_event(x) do { } while (0)
1451#endif 1451#endif
1452 1452
1453static int ip_mc_del_src(struct in_device *in_dev, __u32 *pmca, int sfmode, 1453static int ip_mc_del_src(struct in_device *in_dev, __be32 *pmca, int sfmode,
1454 int sfcount, __u32 *psfsrc, int delta) 1454 int sfcount, __be32 *psfsrc, int delta)
1455{ 1455{
1456 struct ip_mc_list *pmc; 1456 struct ip_mc_list *pmc;
1457 int changerec = 0; 1457 int changerec = 0;
@@ -1517,7 +1517,7 @@ out_unlock:
1517 * Add multicast single-source filter to the interface list 1517 * Add multicast single-source filter to the interface list
1518 */ 1518 */
1519static int ip_mc_add1_src(struct ip_mc_list *pmc, int sfmode, 1519static int ip_mc_add1_src(struct ip_mc_list *pmc, int sfmode,
1520 __u32 *psfsrc, int delta) 1520 __be32 *psfsrc, int delta)
1521{ 1521{
1522 struct ip_sf_list *psf, *psf_prev; 1522 struct ip_sf_list *psf, *psf_prev;
1523 1523
@@ -1623,8 +1623,8 @@ static int sf_setstate(struct ip_mc_list *pmc)
1623/* 1623/*
1624 * Add multicast source filter list to the interface list 1624 * Add multicast source filter list to the interface list
1625 */ 1625 */
1626static int ip_mc_add_src(struct in_device *in_dev, __u32 *pmca, int sfmode, 1626static int ip_mc_add_src(struct in_device *in_dev, __be32 *pmca, int sfmode,
1627 int sfcount, __u32 *psfsrc, int delta) 1627 int sfcount, __be32 *psfsrc, int delta)
1628{ 1628{
1629 struct ip_mc_list *pmc; 1629 struct ip_mc_list *pmc;
1630 int isexclude; 1630 int isexclude;
@@ -1717,7 +1717,7 @@ static void ip_mc_clear_src(struct ip_mc_list *pmc)
1717int ip_mc_join_group(struct sock *sk , struct ip_mreqn *imr) 1717int ip_mc_join_group(struct sock *sk , struct ip_mreqn *imr)
1718{ 1718{
1719 int err; 1719 int err;
1720 u32 addr = imr->imr_multiaddr.s_addr; 1720 __be32 addr = imr->imr_multiaddr.s_addr;
1721 struct ip_mc_socklist *iml=NULL, *i; 1721 struct ip_mc_socklist *iml=NULL, *i;
1722 struct in_device *in_dev; 1722 struct in_device *in_dev;
1723 struct inet_sock *inet = inet_sk(sk); 1723 struct inet_sock *inet = inet_sk(sk);
@@ -1791,7 +1791,7 @@ int ip_mc_leave_group(struct sock *sk, struct ip_mreqn *imr)
1791 struct inet_sock *inet = inet_sk(sk); 1791 struct inet_sock *inet = inet_sk(sk);
1792 struct ip_mc_socklist *iml, **imlp; 1792 struct ip_mc_socklist *iml, **imlp;
1793 struct in_device *in_dev; 1793 struct in_device *in_dev;
1794 u32 group = imr->imr_multiaddr.s_addr; 1794 __be32 group = imr->imr_multiaddr.s_addr;
1795 u32 ifindex; 1795 u32 ifindex;
1796 int ret = -EADDRNOTAVAIL; 1796 int ret = -EADDRNOTAVAIL;
1797 1797
@@ -1829,7 +1829,7 @@ int ip_mc_source(int add, int omode, struct sock *sk, struct
1829{ 1829{
1830 int err; 1830 int err;
1831 struct ip_mreqn imr; 1831 struct ip_mreqn imr;
1832 u32 addr = mreqs->imr_multiaddr; 1832 __be32 addr = mreqs->imr_multiaddr;
1833 struct ip_mc_socklist *pmc; 1833 struct ip_mc_socklist *pmc;
1834 struct in_device *in_dev = NULL; 1834 struct in_device *in_dev = NULL;
1835 struct inet_sock *inet = inet_sk(sk); 1835 struct inet_sock *inet = inet_sk(sk);
@@ -1883,7 +1883,7 @@ int ip_mc_source(int add, int omode, struct sock *sk, struct
1883 rv = !0; 1883 rv = !0;
1884 for (i=0; i<psl->sl_count; i++) { 1884 for (i=0; i<psl->sl_count; i++) {
1885 rv = memcmp(&psl->sl_addr[i], &mreqs->imr_sourceaddr, 1885 rv = memcmp(&psl->sl_addr[i], &mreqs->imr_sourceaddr,
1886 sizeof(__u32)); 1886 sizeof(__be32));
1887 if (rv == 0) 1887 if (rv == 0)
1888 break; 1888 break;
1889 } 1889 }
@@ -1935,7 +1935,7 @@ int ip_mc_source(int add, int omode, struct sock *sk, struct
1935 rv = 1; /* > 0 for insert logic below if sl_count is 0 */ 1935 rv = 1; /* > 0 for insert logic below if sl_count is 0 */
1936 for (i=0; i<psl->sl_count; i++) { 1936 for (i=0; i<psl->sl_count; i++) {
1937 rv = memcmp(&psl->sl_addr[i], &mreqs->imr_sourceaddr, 1937 rv = memcmp(&psl->sl_addr[i], &mreqs->imr_sourceaddr,
1938 sizeof(__u32)); 1938 sizeof(__be32));
1939 if (rv == 0) 1939 if (rv == 0)
1940 break; 1940 break;
1941 } 1941 }
@@ -1960,7 +1960,7 @@ int ip_mc_msfilter(struct sock *sk, struct ip_msfilter *msf, int ifindex)
1960{ 1960{
1961 int err = 0; 1961 int err = 0;
1962 struct ip_mreqn imr; 1962 struct ip_mreqn imr;
1963 u32 addr = msf->imsf_multiaddr; 1963 __be32 addr = msf->imsf_multiaddr;
1964 struct ip_mc_socklist *pmc; 1964 struct ip_mc_socklist *pmc;
1965 struct in_device *in_dev; 1965 struct in_device *in_dev;
1966 struct inet_sock *inet = inet_sk(sk); 1966 struct inet_sock *inet = inet_sk(sk);
@@ -2044,7 +2044,7 @@ int ip_mc_msfget(struct sock *sk, struct ip_msfilter *msf,
2044{ 2044{
2045 int err, len, count, copycount; 2045 int err, len, count, copycount;
2046 struct ip_mreqn imr; 2046 struct ip_mreqn imr;
2047 u32 addr = msf->imsf_multiaddr; 2047 __be32 addr = msf->imsf_multiaddr;
2048 struct ip_mc_socklist *pmc; 2048 struct ip_mc_socklist *pmc;
2049 struct in_device *in_dev; 2049 struct in_device *in_dev;
2050 struct inet_sock *inet = inet_sk(sk); 2050 struct inet_sock *inet = inet_sk(sk);
@@ -2103,7 +2103,7 @@ int ip_mc_gsfget(struct sock *sk, struct group_filter *gsf,
2103{ 2103{
2104 int err, i, count, copycount; 2104 int err, i, count, copycount;
2105 struct sockaddr_in *psin; 2105 struct sockaddr_in *psin;
2106 u32 addr; 2106 __be32 addr;
2107 struct ip_mc_socklist *pmc; 2107 struct ip_mc_socklist *pmc;
2108 struct inet_sock *inet = inet_sk(sk); 2108 struct inet_sock *inet = inet_sk(sk);
2109 struct ip_sf_socklist *psl; 2109 struct ip_sf_socklist *psl;
@@ -2156,7 +2156,7 @@ done:
2156/* 2156/*
2157 * check if a multicast source filter allows delivery for a given <src,dst,intf> 2157 * check if a multicast source filter allows delivery for a given <src,dst,intf>
2158 */ 2158 */
2159int ip_mc_sf_allow(struct sock *sk, u32 loc_addr, u32 rmt_addr, int dif) 2159int ip_mc_sf_allow(struct sock *sk, __be32 loc_addr, __be32 rmt_addr, int dif)
2160{ 2160{
2161 struct inet_sock *inet = inet_sk(sk); 2161 struct inet_sock *inet = inet_sk(sk);
2162 struct ip_mc_socklist *pmc; 2162 struct ip_mc_socklist *pmc;
@@ -2216,7 +2216,7 @@ void ip_mc_drop_socket(struct sock *sk)
2216 rtnl_unlock(); 2216 rtnl_unlock();
2217} 2217}
2218 2218
2219int ip_check_mc(struct in_device *in_dev, u32 mc_addr, u32 src_addr, u16 proto) 2219int ip_check_mc(struct in_device *in_dev, __be32 mc_addr, __be32 src_addr, u16 proto)
2220{ 2220{
2221 struct ip_mc_list *im; 2221 struct ip_mc_list *im;
2222 struct ip_sf_list *psf; 2222 struct ip_sf_list *psf;
diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c
index 07204391d083..96bbe2a0aa1b 100644
--- a/net/ipv4/inet_connection_sock.c
+++ b/net/ipv4/inet_connection_sock.c
@@ -39,7 +39,7 @@ int sysctl_local_port_range[2] = { 1024, 4999 };
39int inet_csk_bind_conflict(const struct sock *sk, 39int inet_csk_bind_conflict(const struct sock *sk,
40 const struct inet_bind_bucket *tb) 40 const struct inet_bind_bucket *tb)
41{ 41{
42 const u32 sk_rcv_saddr = inet_rcv_saddr(sk); 42 const __be32 sk_rcv_saddr = inet_rcv_saddr(sk);
43 struct sock *sk2; 43 struct sock *sk2;
44 struct hlist_node *node; 44 struct hlist_node *node;
45 int reuse = sk->sk_reuse; 45 int reuse = sk->sk_reuse;
@@ -52,7 +52,7 @@ int inet_csk_bind_conflict(const struct sock *sk,
52 sk->sk_bound_dev_if == sk2->sk_bound_dev_if)) { 52 sk->sk_bound_dev_if == sk2->sk_bound_dev_if)) {
53 if (!reuse || !sk2->sk_reuse || 53 if (!reuse || !sk2->sk_reuse ||
54 sk2->sk_state == TCP_LISTEN) { 54 sk2->sk_state == TCP_LISTEN) {
55 const u32 sk2_rcv_saddr = inet_rcv_saddr(sk2); 55 const __be32 sk2_rcv_saddr = inet_rcv_saddr(sk2);
56 if (!sk2_rcv_saddr || !sk_rcv_saddr || 56 if (!sk2_rcv_saddr || !sk_rcv_saddr ||
57 sk2_rcv_saddr == sk_rcv_saddr) 57 sk2_rcv_saddr == sk_rcv_saddr)
58 break; 58 break;
@@ -342,10 +342,10 @@ struct dst_entry* inet_csk_route_req(struct sock *sk,
342 342
343EXPORT_SYMBOL_GPL(inet_csk_route_req); 343EXPORT_SYMBOL_GPL(inet_csk_route_req);
344 344
345static inline u32 inet_synq_hash(const u32 raddr, const u16 rport, 345static inline u32 inet_synq_hash(const __be32 raddr, const __be16 rport,
346 const u32 rnd, const u16 synq_hsize) 346 const u32 rnd, const u16 synq_hsize)
347{ 347{
348 return jhash_2words(raddr, (u32)rport, rnd) & (synq_hsize - 1); 348 return jhash_2words((__force u32)raddr, (__force u32)rport, rnd) & (synq_hsize - 1);
349} 349}
350 350
351#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) 351#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
@@ -356,8 +356,8 @@ static inline u32 inet_synq_hash(const u32 raddr, const u16 rport,
356 356
357struct request_sock *inet_csk_search_req(const struct sock *sk, 357struct request_sock *inet_csk_search_req(const struct sock *sk,
358 struct request_sock ***prevp, 358 struct request_sock ***prevp,
359 const __u16 rport, const __u32 raddr, 359 const __be16 rport, const __be32 raddr,
360 const __u32 laddr) 360 const __be32 laddr)
361{ 361{
362 const struct inet_connection_sock *icsk = inet_csk(sk); 362 const struct inet_connection_sock *icsk = inet_csk(sk);
363 struct listen_sock *lopt = icsk->icsk_accept_queue.listen_opt; 363 struct listen_sock *lopt = icsk->icsk_accept_queue.listen_opt;
diff --git a/net/ipv4/inet_diag.c b/net/ipv4/inet_diag.c
index 492858e6faf0..77761ac4f7bb 100644
--- a/net/ipv4/inet_diag.c
+++ b/net/ipv4/inet_diag.c
@@ -36,8 +36,8 @@
36static const struct inet_diag_handler **inet_diag_table; 36static const struct inet_diag_handler **inet_diag_table;
37 37
38struct inet_diag_entry { 38struct inet_diag_entry {
39 u32 *saddr; 39 __be32 *saddr;
40 u32 *daddr; 40 __be32 *daddr;
41 u16 sport; 41 u16 sport;
42 u16 dport; 42 u16 dport;
43 u16 family; 43 u16 family;
@@ -294,7 +294,7 @@ out:
294 return err; 294 return err;
295} 295}
296 296
297static int bitstring_match(const u32 *a1, const u32 *a2, int bits) 297static int bitstring_match(const __be32 *a1, const __be32 *a2, int bits)
298{ 298{
299 int words = bits >> 5; 299 int words = bits >> 5;
300 300
@@ -305,8 +305,8 @@ static int bitstring_match(const u32 *a1, const u32 *a2, int bits)
305 return 0; 305 return 0;
306 } 306 }
307 if (bits) { 307 if (bits) {
308 __u32 w1, w2; 308 __be32 w1, w2;
309 __u32 mask; 309 __be32 mask;
310 310
311 w1 = a1[words]; 311 w1 = a1[words];
312 w2 = a2[words]; 312 w2 = a2[words];
@@ -352,7 +352,7 @@ static int inet_diag_bc_run(const void *bc, int len,
352 case INET_DIAG_BC_S_COND: 352 case INET_DIAG_BC_S_COND:
353 case INET_DIAG_BC_D_COND: { 353 case INET_DIAG_BC_D_COND: {
354 struct inet_diag_hostcond *cond; 354 struct inet_diag_hostcond *cond;
355 u32 *addr; 355 __be32 *addr;
356 356
357 cond = (struct inet_diag_hostcond *)(op + 1); 357 cond = (struct inet_diag_hostcond *)(op + 1);
358 if (cond->port != -1 && 358 if (cond->port != -1 &&
diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c
index fb296c9a7f3f..244c4f445c7d 100644
--- a/net/ipv4/inet_hashtables.c
+++ b/net/ipv4/inet_hashtables.c
@@ -125,7 +125,7 @@ EXPORT_SYMBOL(inet_listen_wlock);
125 * wildcarded during the search since they can never be otherwise. 125 * wildcarded during the search since they can never be otherwise.
126 */ 126 */
127static struct sock *inet_lookup_listener_slow(const struct hlist_head *head, 127static struct sock *inet_lookup_listener_slow(const struct hlist_head *head,
128 const u32 daddr, 128 const __be32 daddr,
129 const unsigned short hnum, 129 const unsigned short hnum,
130 const int dif) 130 const int dif)
131{ 131{
@@ -137,7 +137,7 @@ static struct sock *inet_lookup_listener_slow(const struct hlist_head *head,
137 const struct inet_sock *inet = inet_sk(sk); 137 const struct inet_sock *inet = inet_sk(sk);
138 138
139 if (inet->num == hnum && !ipv6_only_sock(sk)) { 139 if (inet->num == hnum && !ipv6_only_sock(sk)) {
140 const __u32 rcv_saddr = inet->rcv_saddr; 140 const __be32 rcv_saddr = inet->rcv_saddr;
141 int score = sk->sk_family == PF_INET ? 1 : 0; 141 int score = sk->sk_family == PF_INET ? 1 : 0;
142 142
143 if (rcv_saddr) { 143 if (rcv_saddr) {
@@ -163,7 +163,7 @@ static struct sock *inet_lookup_listener_slow(const struct hlist_head *head,
163 163
164/* Optimize the common listener case. */ 164/* Optimize the common listener case. */
165struct sock *__inet_lookup_listener(struct inet_hashinfo *hashinfo, 165struct sock *__inet_lookup_listener(struct inet_hashinfo *hashinfo,
166 const u32 daddr, const unsigned short hnum, 166 const __be32 daddr, const unsigned short hnum,
167 const int dif) 167 const int dif)
168{ 168{
169 struct sock *sk = NULL; 169 struct sock *sk = NULL;
@@ -197,11 +197,11 @@ static int __inet_check_established(struct inet_timewait_death_row *death_row,
197{ 197{
198 struct inet_hashinfo *hinfo = death_row->hashinfo; 198 struct inet_hashinfo *hinfo = death_row->hashinfo;
199 struct inet_sock *inet = inet_sk(sk); 199 struct inet_sock *inet = inet_sk(sk);
200 u32 daddr = inet->rcv_saddr; 200 __be32 daddr = inet->rcv_saddr;
201 u32 saddr = inet->daddr; 201 __be32 saddr = inet->daddr;
202 int dif = sk->sk_bound_dev_if; 202 int dif = sk->sk_bound_dev_if;
203 INET_ADDR_COOKIE(acookie, saddr, daddr) 203 INET_ADDR_COOKIE(acookie, saddr, daddr)
204 const __u32 ports = INET_COMBINED_PORTS(inet->dport, lport); 204 const __portpair ports = INET_COMBINED_PORTS(inet->dport, lport);
205 unsigned int hash = inet_ehashfn(daddr, lport, saddr, inet->dport); 205 unsigned int hash = inet_ehashfn(daddr, lport, saddr, inet->dport);
206 struct inet_ehash_bucket *head = inet_ehash_bucket(hinfo, hash); 206 struct inet_ehash_bucket *head = inet_ehash_bucket(hinfo, hash);
207 struct sock *sk2; 207 struct sock *sk2;
diff --git a/net/ipv4/inetpeer.c b/net/ipv4/inetpeer.c
index a675602ef295..2b1a54b59c48 100644
--- a/net/ipv4/inetpeer.c
+++ b/net/ipv4/inetpeer.c
@@ -163,7 +163,7 @@ static void unlink_from_unused(struct inet_peer *p)
163 for (u = peer_root; u != peer_avl_empty; ) { \ 163 for (u = peer_root; u != peer_avl_empty; ) { \
164 if (daddr == u->v4daddr) \ 164 if (daddr == u->v4daddr) \
165 break; \ 165 break; \
166 if (daddr < u->v4daddr) \ 166 if ((__force __u32)daddr < (__force __u32)u->v4daddr) \
167 v = &u->avl_left; \ 167 v = &u->avl_left; \
168 else \ 168 else \
169 v = &u->avl_right; \ 169 v = &u->avl_right; \
@@ -368,7 +368,7 @@ static int cleanup_once(unsigned long ttl)
368} 368}
369 369
370/* Called with or without local BH being disabled. */ 370/* Called with or without local BH being disabled. */
371struct inet_peer *inet_getpeer(__u32 daddr, int create) 371struct inet_peer *inet_getpeer(__be32 daddr, int create)
372{ 372{
373 struct inet_peer *p, *n; 373 struct inet_peer *p, *n;
374 struct inet_peer **stack[PEER_MAXDEPTH], ***stackptr; 374 struct inet_peer **stack[PEER_MAXDEPTH], ***stackptr;
diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c
index 165d72859ddf..74046efdf875 100644
--- a/net/ipv4/ip_fragment.c
+++ b/net/ipv4/ip_fragment.c
@@ -77,9 +77,9 @@ struct ipq {
77 struct hlist_node list; 77 struct hlist_node list;
78 struct list_head lru_list; /* lru list member */ 78 struct list_head lru_list; /* lru list member */
79 u32 user; 79 u32 user;
80 u32 saddr; 80 __be32 saddr;
81 u32 daddr; 81 __be32 daddr;
82 u16 id; 82 __be16 id;
83 u8 protocol; 83 u8 protocol;
84 u8 last_in; 84 u8 last_in;
85#define COMPLETE 4 85#define COMPLETE 4
@@ -123,9 +123,10 @@ static __inline__ void ipq_unlink(struct ipq *ipq)
123 write_unlock(&ipfrag_lock); 123 write_unlock(&ipfrag_lock);
124} 124}
125 125
126static unsigned int ipqhashfn(u16 id, u32 saddr, u32 daddr, u8 prot) 126static unsigned int ipqhashfn(__be16 id, __be32 saddr, __be32 daddr, u8 prot)
127{ 127{
128 return jhash_3words((u32)id << 16 | prot, saddr, daddr, 128 return jhash_3words((__force u32)id << 16 | prot,
129 (__force u32)saddr, (__force u32)daddr,
129 ipfrag_hash_rnd) & (IPQ_HASHSZ - 1); 130 ipfrag_hash_rnd) & (IPQ_HASHSZ - 1);
130} 131}
131 132
@@ -387,8 +388,8 @@ out_nomem:
387static inline struct ipq *ip_find(struct iphdr *iph, u32 user) 388static inline struct ipq *ip_find(struct iphdr *iph, u32 user)
388{ 389{
389 __be16 id = iph->id; 390 __be16 id = iph->id;
390 __u32 saddr = iph->saddr; 391 __be32 saddr = iph->saddr;
391 __u32 daddr = iph->daddr; 392 __be32 daddr = iph->daddr;
392 __u8 protocol = iph->protocol; 393 __u8 protocol = iph->protocol;
393 unsigned int hash; 394 unsigned int hash;
394 struct ipq *qp; 395 struct ipq *qp;
diff --git a/net/ipv4/ip_options.c b/net/ipv4/ip_options.c
index e7437c091326..8dabbfc31267 100644
--- a/net/ipv4/ip_options.c
+++ b/net/ipv4/ip_options.c
@@ -38,7 +38,7 @@
38 */ 38 */
39 39
40void ip_options_build(struct sk_buff * skb, struct ip_options * opt, 40void ip_options_build(struct sk_buff * skb, struct ip_options * opt,
41 u32 daddr, struct rtable *rt, int is_frag) 41 __be32 daddr, struct rtable *rt, int is_frag)
42{ 42{
43 unsigned char * iph = skb->nh.raw; 43 unsigned char * iph = skb->nh.raw;
44 44
@@ -57,7 +57,7 @@ void ip_options_build(struct sk_buff * skb, struct ip_options * opt,
57 ip_rt_get_source(iph+opt->ts+iph[opt->ts+2]-9, rt); 57 ip_rt_get_source(iph+opt->ts+iph[opt->ts+2]-9, rt);
58 if (opt->ts_needtime) { 58 if (opt->ts_needtime) {
59 struct timeval tv; 59 struct timeval tv;
60 __u32 midtime; 60 __be32 midtime;
61 do_gettimeofday(&tv); 61 do_gettimeofday(&tv);
62 midtime = htonl((tv.tv_sec % 86400) * 1000 + tv.tv_usec / 1000); 62 midtime = htonl((tv.tv_sec % 86400) * 1000 + tv.tv_usec / 1000);
63 memcpy(iph+opt->ts+iph[opt->ts+2]-5, &midtime, 4); 63 memcpy(iph+opt->ts+iph[opt->ts+2]-5, &midtime, 4);
@@ -91,7 +91,7 @@ int ip_options_echo(struct ip_options * dopt, struct sk_buff * skb)
91 unsigned char *sptr, *dptr; 91 unsigned char *sptr, *dptr;
92 int soffset, doffset; 92 int soffset, doffset;
93 int optlen; 93 int optlen;
94 u32 daddr; 94 __be32 daddr;
95 95
96 memset(dopt, 0, sizeof(struct ip_options)); 96 memset(dopt, 0, sizeof(struct ip_options));
97 97
@@ -148,7 +148,7 @@ int ip_options_echo(struct ip_options * dopt, struct sk_buff * skb)
148 dopt->ts_needtime = 0; 148 dopt->ts_needtime = 0;
149 149
150 if (soffset + 8 <= optlen) { 150 if (soffset + 8 <= optlen) {
151 __u32 addr; 151 __be32 addr;
152 152
153 memcpy(&addr, sptr+soffset-1, 4); 153 memcpy(&addr, sptr+soffset-1, 4);
154 if (inet_addr_type(addr) != RTN_LOCAL) { 154 if (inet_addr_type(addr) != RTN_LOCAL) {
@@ -165,7 +165,7 @@ int ip_options_echo(struct ip_options * dopt, struct sk_buff * skb)
165 } 165 }
166 if (sopt->srr) { 166 if (sopt->srr) {
167 unsigned char * start = sptr+sopt->srr; 167 unsigned char * start = sptr+sopt->srr;
168 u32 faddr; 168 __be32 faddr;
169 169
170 optlen = start[1]; 170 optlen = start[1];
171 soffset = start[2]; 171 soffset = start[2];
@@ -362,7 +362,7 @@ int ip_options_compile(struct ip_options * opt, struct sk_buff * skb)
362 goto error; 362 goto error;
363 } 363 }
364 if (optptr[2] <= optlen) { 364 if (optptr[2] <= optlen) {
365 __u32 * timeptr = NULL; 365 __be32 *timeptr = NULL;
366 if (optptr[2]+3 > optptr[1]) { 366 if (optptr[2]+3 > optptr[1]) {
367 pp_ptr = optptr + 2; 367 pp_ptr = optptr + 2;
368 goto error; 368 goto error;
@@ -371,7 +371,7 @@ int ip_options_compile(struct ip_options * opt, struct sk_buff * skb)
371 case IPOPT_TS_TSONLY: 371 case IPOPT_TS_TSONLY:
372 opt->ts = optptr - iph; 372 opt->ts = optptr - iph;
373 if (skb) 373 if (skb)
374 timeptr = (__u32*)&optptr[optptr[2]-1]; 374 timeptr = (__be32*)&optptr[optptr[2]-1];
375 opt->ts_needtime = 1; 375 opt->ts_needtime = 1;
376 optptr[2] += 4; 376 optptr[2] += 4;
377 break; 377 break;
@@ -383,7 +383,7 @@ int ip_options_compile(struct ip_options * opt, struct sk_buff * skb)
383 opt->ts = optptr - iph; 383 opt->ts = optptr - iph;
384 if (skb) { 384 if (skb) {
385 memcpy(&optptr[optptr[2]-1], &rt->rt_spec_dst, 4); 385 memcpy(&optptr[optptr[2]-1], &rt->rt_spec_dst, 4);
386 timeptr = (__u32*)&optptr[optptr[2]+3]; 386 timeptr = (__be32*)&optptr[optptr[2]+3];
387 } 387 }
388 opt->ts_needaddr = 1; 388 opt->ts_needaddr = 1;
389 opt->ts_needtime = 1; 389 opt->ts_needtime = 1;
@@ -396,12 +396,12 @@ int ip_options_compile(struct ip_options * opt, struct sk_buff * skb)
396 } 396 }
397 opt->ts = optptr - iph; 397 opt->ts = optptr - iph;
398 { 398 {
399 u32 addr; 399 __be32 addr;
400 memcpy(&addr, &optptr[optptr[2]-1], 4); 400 memcpy(&addr, &optptr[optptr[2]-1], 4);
401 if (inet_addr_type(addr) == RTN_UNICAST) 401 if (inet_addr_type(addr) == RTN_UNICAST)
402 break; 402 break;
403 if (skb) 403 if (skb)
404 timeptr = (__u32*)&optptr[optptr[2]+3]; 404 timeptr = (__be32*)&optptr[optptr[2]+3];
405 } 405 }
406 opt->ts_needtime = 1; 406 opt->ts_needtime = 1;
407 optptr[2] += 8; 407 optptr[2] += 8;
@@ -415,10 +415,10 @@ int ip_options_compile(struct ip_options * opt, struct sk_buff * skb)
415 } 415 }
416 if (timeptr) { 416 if (timeptr) {
417 struct timeval tv; 417 struct timeval tv;
418 __u32 midtime; 418 __be32 midtime;
419 do_gettimeofday(&tv); 419 do_gettimeofday(&tv);
420 midtime = htonl((tv.tv_sec % 86400) * 1000 + tv.tv_usec / 1000); 420 midtime = htonl((tv.tv_sec % 86400) * 1000 + tv.tv_usec / 1000);
421 memcpy(timeptr, &midtime, sizeof(__u32)); 421 memcpy(timeptr, &midtime, sizeof(__be32));
422 opt->is_changed = 1; 422 opt->is_changed = 1;
423 } 423 }
424 } else { 424 } else {
@@ -607,7 +607,7 @@ int ip_options_rcv_srr(struct sk_buff *skb)
607{ 607{
608 struct ip_options *opt = &(IPCB(skb)->opt); 608 struct ip_options *opt = &(IPCB(skb)->opt);
609 int srrspace, srrptr; 609 int srrspace, srrptr;
610 u32 nexthop; 610 __be32 nexthop;
611 struct iphdr *iph = skb->nh.iph; 611 struct iphdr *iph = skb->nh.iph;
612 unsigned char * optptr = skb->nh.raw + opt->srr; 612 unsigned char * optptr = skb->nh.raw + opt->srr;
613 struct rtable *rt = (struct rtable*)skb->dst; 613 struct rtable *rt = (struct rtable*)skb->dst;
diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c
index 97aee76fb746..fc195a44fc2e 100644
--- a/net/ipv4/ip_output.c
+++ b/net/ipv4/ip_output.c
@@ -118,7 +118,7 @@ static inline int ip_select_ttl(struct inet_sock *inet, struct dst_entry *dst)
118 * 118 *
119 */ 119 */
120int ip_build_and_send_pkt(struct sk_buff *skb, struct sock *sk, 120int ip_build_and_send_pkt(struct sk_buff *skb, struct sock *sk,
121 u32 saddr, u32 daddr, struct ip_options *opt) 121 __be32 saddr, __be32 daddr, struct ip_options *opt)
122{ 122{
123 struct inet_sock *inet = inet_sk(sk); 123 struct inet_sock *inet = inet_sk(sk);
124 struct rtable *rt = (struct rtable *)skb->dst; 124 struct rtable *rt = (struct rtable *)skb->dst;
@@ -306,7 +306,7 @@ int ip_queue_xmit(struct sk_buff *skb, int ipfragok)
306 /* Make sure we can route this packet. */ 306 /* Make sure we can route this packet. */
307 rt = (struct rtable *)__sk_dst_check(sk, 0); 307 rt = (struct rtable *)__sk_dst_check(sk, 0);
308 if (rt == NULL) { 308 if (rt == NULL) {
309 u32 daddr; 309 __be32 daddr;
310 310
311 /* Use correct destination address if we have options. */ 311 /* Use correct destination address if we have options. */
312 daddr = inet->daddr; 312 daddr = inet->daddr;
@@ -1340,7 +1340,7 @@ void ip_send_reply(struct sock *sk, struct sk_buff *skb, struct ip_reply_arg *ar
1340 char data[40]; 1340 char data[40];
1341 } replyopts; 1341 } replyopts;
1342 struct ipcm_cookie ipc; 1342 struct ipcm_cookie ipc;
1343 u32 daddr; 1343 __be32 daddr;
1344 struct rtable *rt = (struct rtable*)skb->dst; 1344 struct rtable *rt = (struct rtable*)skb->dst;
1345 1345
1346 if (ip_options_echo(&replyopts.opt, skb)) 1346 if (ip_options_echo(&replyopts.opt, skb))
diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c
index 2d05c4133d3e..4b132953bcc2 100644
--- a/net/ipv4/ip_sockglue.c
+++ b/net/ipv4/ip_sockglue.c
@@ -254,7 +254,7 @@ int ip_ra_control(struct sock *sk, unsigned char on, void (*destructor)(struct s
254} 254}
255 255
256void ip_icmp_error(struct sock *sk, struct sk_buff *skb, int err, 256void ip_icmp_error(struct sock *sk, struct sk_buff *skb, int err,
257 u16 port, u32 info, u8 *payload) 257 __be16 port, u32 info, u8 *payload)
258{ 258{
259 struct inet_sock *inet = inet_sk(sk); 259 struct inet_sock *inet = inet_sk(sk);
260 struct sock_exterr_skb *serr; 260 struct sock_exterr_skb *serr;
@@ -283,7 +283,7 @@ void ip_icmp_error(struct sock *sk, struct sk_buff *skb, int err,
283 kfree_skb(skb); 283 kfree_skb(skb);
284} 284}
285 285
286void ip_local_error(struct sock *sk, int err, u32 daddr, u16 port, u32 info) 286void ip_local_error(struct sock *sk, int err, __be32 daddr, __be16 port, u32 info)
287{ 287{
288 struct inet_sock *inet = inet_sk(sk); 288 struct inet_sock *inet = inet_sk(sk);
289 struct sock_exterr_skb *serr; 289 struct sock_exterr_skb *serr;
diff --git a/net/ipv4/ipcomp.c b/net/ipv4/ipcomp.c
index 17342430a843..2017d36024d4 100644
--- a/net/ipv4/ipcomp.c
+++ b/net/ipv4/ipcomp.c
@@ -183,7 +183,7 @@ out_ok:
183 183
184static void ipcomp4_err(struct sk_buff *skb, u32 info) 184static void ipcomp4_err(struct sk_buff *skb, u32 info)
185{ 185{
186 u32 spi; 186 __be32 spi;
187 struct iphdr *iph = (struct iphdr *)skb->data; 187 struct iphdr *iph = (struct iphdr *)skb->data;
188 struct ip_comp_hdr *ipch = (struct ip_comp_hdr *)(skb->data+(iph->ihl<<2)); 188 struct ip_comp_hdr *ipch = (struct ip_comp_hdr *)(skb->data+(iph->ihl<<2));
189 struct xfrm_state *x; 189 struct xfrm_state *x;
diff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c
index ba49588da242..97cfa97c8abb 100644
--- a/net/ipv4/ipmr.c
+++ b/net/ipv4/ipmr.c
@@ -462,7 +462,7 @@ static int vif_add(struct vifctl *vifc, int mrtsock)
462 return 0; 462 return 0;
463} 463}
464 464
465static struct mfc_cache *ipmr_cache_find(__u32 origin, __u32 mcastgrp) 465static struct mfc_cache *ipmr_cache_find(__be32 origin, __be32 mcastgrp)
466{ 466{
467 int line=MFC_HASH(mcastgrp,origin); 467 int line=MFC_HASH(mcastgrp,origin);
468 struct mfc_cache *c; 468 struct mfc_cache *c;
@@ -1097,7 +1097,7 @@ static struct notifier_block ip_mr_notifier={
1097 * important for multicast video. 1097 * important for multicast video.
1098 */ 1098 */
1099 1099
1100static void ip_encap(struct sk_buff *skb, u32 saddr, u32 daddr) 1100static void ip_encap(struct sk_buff *skb, __be32 saddr, __be32 daddr)
1101{ 1101{
1102 struct iphdr *iph = (struct iphdr *)skb_push(skb,sizeof(struct iphdr)); 1102 struct iphdr *iph = (struct iphdr *)skb_push(skb,sizeof(struct iphdr));
1103 1103
diff --git a/net/ipv4/ipvs/ip_vs_conn.c b/net/ipv4/ipvs/ip_vs_conn.c
index 87b83813cf2c..8832eb517d52 100644
--- a/net/ipv4/ipvs/ip_vs_conn.c
+++ b/net/ipv4/ipvs/ip_vs_conn.c
@@ -115,9 +115,9 @@ static inline void ct_write_unlock_bh(unsigned key)
115/* 115/*
116 * Returns hash value for IPVS connection entry 116 * Returns hash value for IPVS connection entry
117 */ 117 */
118static unsigned int ip_vs_conn_hashkey(unsigned proto, __u32 addr, __u16 port) 118static unsigned int ip_vs_conn_hashkey(unsigned proto, __be32 addr, __be16 port)
119{ 119{
120 return jhash_3words(addr, port, proto, ip_vs_conn_rnd) 120 return jhash_3words((__force u32)addr, (__force u32)port, proto, ip_vs_conn_rnd)
121 & IP_VS_CONN_TAB_MASK; 121 & IP_VS_CONN_TAB_MASK;
122} 122}
123 123
@@ -188,7 +188,7 @@ static inline int ip_vs_conn_unhash(struct ip_vs_conn *cp)
188 * d_addr, d_port: pkt dest address (load balancer) 188 * d_addr, d_port: pkt dest address (load balancer)
189 */ 189 */
190static inline struct ip_vs_conn *__ip_vs_conn_in_get 190static inline struct ip_vs_conn *__ip_vs_conn_in_get
191(int protocol, __u32 s_addr, __u16 s_port, __u32 d_addr, __u16 d_port) 191(int protocol, __be32 s_addr, __be16 s_port, __be32 d_addr, __be16 d_port)
192{ 192{
193 unsigned hash; 193 unsigned hash;
194 struct ip_vs_conn *cp; 194 struct ip_vs_conn *cp;
@@ -215,7 +215,7 @@ static inline struct ip_vs_conn *__ip_vs_conn_in_get
215} 215}
216 216
217struct ip_vs_conn *ip_vs_conn_in_get 217struct ip_vs_conn *ip_vs_conn_in_get
218(int protocol, __u32 s_addr, __u16 s_port, __u32 d_addr, __u16 d_port) 218(int protocol, __be32 s_addr, __be16 s_port, __be32 d_addr, __be16 d_port)
219{ 219{
220 struct ip_vs_conn *cp; 220 struct ip_vs_conn *cp;
221 221
@@ -234,7 +234,7 @@ struct ip_vs_conn *ip_vs_conn_in_get
234 234
235/* Get reference to connection template */ 235/* Get reference to connection template */
236struct ip_vs_conn *ip_vs_ct_in_get 236struct ip_vs_conn *ip_vs_ct_in_get
237(int protocol, __u32 s_addr, __u16 s_port, __u32 d_addr, __u16 d_port) 237(int protocol, __be32 s_addr, __be16 s_port, __be32 d_addr, __be16 d_port)
238{ 238{
239 unsigned hash; 239 unsigned hash;
240 struct ip_vs_conn *cp; 240 struct ip_vs_conn *cp;
@@ -274,7 +274,7 @@ struct ip_vs_conn *ip_vs_ct_in_get
274 * d_addr, d_port: pkt dest address (foreign host) 274 * d_addr, d_port: pkt dest address (foreign host)
275 */ 275 */
276struct ip_vs_conn *ip_vs_conn_out_get 276struct ip_vs_conn *ip_vs_conn_out_get
277(int protocol, __u32 s_addr, __u16 s_port, __u32 d_addr, __u16 d_port) 277(int protocol, __be32 s_addr, __be16 s_port, __be32 d_addr, __be16 d_port)
278{ 278{
279 unsigned hash; 279 unsigned hash;
280 struct ip_vs_conn *cp, *ret=NULL; 280 struct ip_vs_conn *cp, *ret=NULL;
@@ -324,7 +324,7 @@ void ip_vs_conn_put(struct ip_vs_conn *cp)
324/* 324/*
325 * Fill a no_client_port connection with a client port number 325 * Fill a no_client_port connection with a client port number
326 */ 326 */
327void ip_vs_conn_fill_cport(struct ip_vs_conn *cp, __u16 cport) 327void ip_vs_conn_fill_cport(struct ip_vs_conn *cp, __be16 cport)
328{ 328{
329 if (ip_vs_conn_unhash(cp)) { 329 if (ip_vs_conn_unhash(cp)) {
330 spin_lock(&cp->lock); 330 spin_lock(&cp->lock);
@@ -508,10 +508,10 @@ int ip_vs_check_template(struct ip_vs_conn *ct)
508 /* 508 /*
509 * Invalidate the connection template 509 * Invalidate the connection template
510 */ 510 */
511 if (ct->vport != 65535) { 511 if (ct->vport != htons(0xffff)) {
512 if (ip_vs_conn_unhash(ct)) { 512 if (ip_vs_conn_unhash(ct)) {
513 ct->dport = 65535; 513 ct->dport = htons(0xffff);
514 ct->vport = 65535; 514 ct->vport = htons(0xffff);
515 ct->cport = 0; 515 ct->cport = 0;
516 ip_vs_conn_hash(ct); 516 ip_vs_conn_hash(ct);
517 } 517 }
@@ -596,8 +596,8 @@ void ip_vs_conn_expire_now(struct ip_vs_conn *cp)
596 * Create a new connection entry and hash it into the ip_vs_conn_tab 596 * Create a new connection entry and hash it into the ip_vs_conn_tab
597 */ 597 */
598struct ip_vs_conn * 598struct ip_vs_conn *
599ip_vs_conn_new(int proto, __u32 caddr, __u16 cport, __u32 vaddr, __u16 vport, 599ip_vs_conn_new(int proto, __be32 caddr, __be16 cport, __be32 vaddr, __be16 vport,
600 __u32 daddr, __u16 dport, unsigned flags, 600 __be32 daddr, __be16 dport, unsigned flags,
601 struct ip_vs_dest *dest) 601 struct ip_vs_dest *dest)
602{ 602{
603 struct ip_vs_conn *cp; 603 struct ip_vs_conn *cp;
diff --git a/net/ipv4/ipvs/ip_vs_core.c b/net/ipv4/ipvs/ip_vs_core.c
index 3f47ad8e1cad..6dee03935f78 100644
--- a/net/ipv4/ipvs/ip_vs_core.c
+++ b/net/ipv4/ipvs/ip_vs_core.c
@@ -209,14 +209,14 @@ int ip_vs_make_skb_writable(struct sk_buff **pskb, int writable_len)
209static struct ip_vs_conn * 209static struct ip_vs_conn *
210ip_vs_sched_persist(struct ip_vs_service *svc, 210ip_vs_sched_persist(struct ip_vs_service *svc,
211 const struct sk_buff *skb, 211 const struct sk_buff *skb,
212 __u16 ports[2]) 212 __be16 ports[2])
213{ 213{
214 struct ip_vs_conn *cp = NULL; 214 struct ip_vs_conn *cp = NULL;
215 struct iphdr *iph = skb->nh.iph; 215 struct iphdr *iph = skb->nh.iph;
216 struct ip_vs_dest *dest; 216 struct ip_vs_dest *dest;
217 struct ip_vs_conn *ct; 217 struct ip_vs_conn *ct;
218 __u16 dport; /* destination port to forward */ 218 __be16 dport; /* destination port to forward */
219 __u32 snet; /* source network of the client, after masking */ 219 __be32 snet; /* source network of the client, after masking */
220 220
221 /* Mask saddr with the netmask to adjust template granularity */ 221 /* Mask saddr with the netmask to adjust template granularity */
222 snet = iph->saddr & svc->netmask; 222 snet = iph->saddr & svc->netmask;
@@ -383,7 +383,7 @@ ip_vs_schedule(struct ip_vs_service *svc, const struct sk_buff *skb)
383 struct ip_vs_conn *cp = NULL; 383 struct ip_vs_conn *cp = NULL;
384 struct iphdr *iph = skb->nh.iph; 384 struct iphdr *iph = skb->nh.iph;
385 struct ip_vs_dest *dest; 385 struct ip_vs_dest *dest;
386 __u16 _ports[2], *pptr; 386 __be16 _ports[2], *pptr;
387 387
388 pptr = skb_header_pointer(skb, iph->ihl*4, 388 pptr = skb_header_pointer(skb, iph->ihl*4,
389 sizeof(_ports), _ports); 389 sizeof(_ports), _ports);
@@ -446,7 +446,7 @@ ip_vs_schedule(struct ip_vs_service *svc, const struct sk_buff *skb)
446int ip_vs_leave(struct ip_vs_service *svc, struct sk_buff *skb, 446int ip_vs_leave(struct ip_vs_service *svc, struct sk_buff *skb,
447 struct ip_vs_protocol *pp) 447 struct ip_vs_protocol *pp)
448{ 448{
449 __u16 _ports[2], *pptr; 449 __be16 _ports[2], *pptr;
450 struct iphdr *iph = skb->nh.iph; 450 struct iphdr *iph = skb->nh.iph;
451 451
452 pptr = skb_header_pointer(skb, iph->ihl*4, 452 pptr = skb_header_pointer(skb, iph->ihl*4,
@@ -576,7 +576,7 @@ void ip_vs_nat_icmp(struct sk_buff *skb, struct ip_vs_protocol *pp,
576 576
577 /* the TCP/UDP port */ 577 /* the TCP/UDP port */
578 if (IPPROTO_TCP == ciph->protocol || IPPROTO_UDP == ciph->protocol) { 578 if (IPPROTO_TCP == ciph->protocol || IPPROTO_UDP == ciph->protocol) {
579 __u16 *ports = (void *)ciph + ciph->ihl*4; 579 __be16 *ports = (void *)ciph + ciph->ihl*4;
580 580
581 if (inout) 581 if (inout)
582 ports[1] = cp->vport; 582 ports[1] = cp->vport;
@@ -775,7 +775,7 @@ ip_vs_out(unsigned int hooknum, struct sk_buff **pskb,
775 if (sysctl_ip_vs_nat_icmp_send && 775 if (sysctl_ip_vs_nat_icmp_send &&
776 (pp->protocol == IPPROTO_TCP || 776 (pp->protocol == IPPROTO_TCP ||
777 pp->protocol == IPPROTO_UDP)) { 777 pp->protocol == IPPROTO_UDP)) {
778 __u16 _ports[2], *pptr; 778 __be16 _ports[2], *pptr;
779 779
780 pptr = skb_header_pointer(skb, ihl, 780 pptr = skb_header_pointer(skb, ihl,
781 sizeof(_ports), _ports); 781 sizeof(_ports), _ports);
diff --git a/net/ipv4/ipvs/ip_vs_ctl.c b/net/ipv4/ipvs/ip_vs_ctl.c
index 6a28fafe910c..f261616e4602 100644
--- a/net/ipv4/ipvs/ip_vs_ctl.c
+++ b/net/ipv4/ipvs/ip_vs_ctl.c
@@ -283,7 +283,7 @@ static atomic_t ip_vs_nullsvc_counter = ATOMIC_INIT(0);
283 * Returns hash value for virtual service 283 * Returns hash value for virtual service
284 */ 284 */
285static __inline__ unsigned 285static __inline__ unsigned
286ip_vs_svc_hashkey(unsigned proto, __u32 addr, __u16 port) 286ip_vs_svc_hashkey(unsigned proto, __be32 addr, __be16 port)
287{ 287{
288 register unsigned porth = ntohs(port); 288 register unsigned porth = ntohs(port);
289 289
@@ -365,7 +365,7 @@ static int ip_vs_svc_unhash(struct ip_vs_service *svc)
365 * Get service by {proto,addr,port} in the service table. 365 * Get service by {proto,addr,port} in the service table.
366 */ 366 */
367static __inline__ struct ip_vs_service * 367static __inline__ struct ip_vs_service *
368__ip_vs_service_get(__u16 protocol, __u32 vaddr, __u16 vport) 368__ip_vs_service_get(__u16 protocol, __be32 vaddr, __be16 vport)
369{ 369{
370 unsigned hash; 370 unsigned hash;
371 struct ip_vs_service *svc; 371 struct ip_vs_service *svc;
@@ -410,7 +410,7 @@ static __inline__ struct ip_vs_service *__ip_vs_svc_fwm_get(__u32 fwmark)
410} 410}
411 411
412struct ip_vs_service * 412struct ip_vs_service *
413ip_vs_service_get(__u32 fwmark, __u16 protocol, __u32 vaddr, __u16 vport) 413ip_vs_service_get(__u32 fwmark, __u16 protocol, __be32 vaddr, __be16 vport)
414{ 414{
415 struct ip_vs_service *svc; 415 struct ip_vs_service *svc;
416 416
@@ -480,7 +480,7 @@ __ip_vs_unbind_svc(struct ip_vs_dest *dest)
480/* 480/*
481 * Returns hash value for real service 481 * Returns hash value for real service
482 */ 482 */
483static __inline__ unsigned ip_vs_rs_hashkey(__u32 addr, __u16 port) 483static __inline__ unsigned ip_vs_rs_hashkey(__be32 addr, __be16 port)
484{ 484{
485 register unsigned porth = ntohs(port); 485 register unsigned porth = ntohs(port);
486 486
@@ -531,7 +531,7 @@ static int ip_vs_rs_unhash(struct ip_vs_dest *dest)
531 * Lookup real service by <proto,addr,port> in the real service table. 531 * Lookup real service by <proto,addr,port> in the real service table.
532 */ 532 */
533struct ip_vs_dest * 533struct ip_vs_dest *
534ip_vs_lookup_real_service(__u16 protocol, __u32 daddr, __u16 dport) 534ip_vs_lookup_real_service(__u16 protocol, __be32 daddr, __be16 dport)
535{ 535{
536 unsigned hash; 536 unsigned hash;
537 struct ip_vs_dest *dest; 537 struct ip_vs_dest *dest;
@@ -562,7 +562,7 @@ ip_vs_lookup_real_service(__u16 protocol, __u32 daddr, __u16 dport)
562 * Lookup destination by {addr,port} in the given service 562 * Lookup destination by {addr,port} in the given service
563 */ 563 */
564static struct ip_vs_dest * 564static struct ip_vs_dest *
565ip_vs_lookup_dest(struct ip_vs_service *svc, __u32 daddr, __u16 dport) 565ip_vs_lookup_dest(struct ip_vs_service *svc, __be32 daddr, __be16 dport)
566{ 566{
567 struct ip_vs_dest *dest; 567 struct ip_vs_dest *dest;
568 568
@@ -591,7 +591,7 @@ ip_vs_lookup_dest(struct ip_vs_service *svc, __u32 daddr, __u16 dport)
591 * scheduling. 591 * scheduling.
592 */ 592 */
593static struct ip_vs_dest * 593static struct ip_vs_dest *
594ip_vs_trash_get_dest(struct ip_vs_service *svc, __u32 daddr, __u16 dport) 594ip_vs_trash_get_dest(struct ip_vs_service *svc, __be32 daddr, __be16 dport)
595{ 595{
596 struct ip_vs_dest *dest, *nxt; 596 struct ip_vs_dest *dest, *nxt;
597 597
@@ -773,8 +773,8 @@ static int
773ip_vs_add_dest(struct ip_vs_service *svc, struct ip_vs_dest_user *udest) 773ip_vs_add_dest(struct ip_vs_service *svc, struct ip_vs_dest_user *udest)
774{ 774{
775 struct ip_vs_dest *dest; 775 struct ip_vs_dest *dest;
776 __u32 daddr = udest->addr; 776 __be32 daddr = udest->addr;
777 __u16 dport = udest->port; 777 __be16 dport = udest->port;
778 int ret; 778 int ret;
779 779
780 EnterFunction(2); 780 EnterFunction(2);
@@ -879,8 +879,8 @@ static int
879ip_vs_edit_dest(struct ip_vs_service *svc, struct ip_vs_dest_user *udest) 879ip_vs_edit_dest(struct ip_vs_service *svc, struct ip_vs_dest_user *udest)
880{ 880{
881 struct ip_vs_dest *dest; 881 struct ip_vs_dest *dest;
882 __u32 daddr = udest->addr; 882 __be32 daddr = udest->addr;
883 __u16 dport = udest->port; 883 __be16 dport = udest->port;
884 884
885 EnterFunction(2); 885 EnterFunction(2);
886 886
@@ -991,8 +991,8 @@ static int
991ip_vs_del_dest(struct ip_vs_service *svc,struct ip_vs_dest_user *udest) 991ip_vs_del_dest(struct ip_vs_service *svc,struct ip_vs_dest_user *udest)
992{ 992{
993 struct ip_vs_dest *dest; 993 struct ip_vs_dest *dest;
994 __u32 daddr = udest->addr; 994 __be32 daddr = udest->addr;
995 __u16 dport = udest->port; 995 __be16 dport = udest->port;
996 996
997 EnterFunction(2); 997 EnterFunction(2);
998 998
diff --git a/net/ipv4/ipvs/ip_vs_dh.c b/net/ipv4/ipvs/ip_vs_dh.c
index 9fee19c4c617..502111fba872 100644
--- a/net/ipv4/ipvs/ip_vs_dh.c
+++ b/net/ipv4/ipvs/ip_vs_dh.c
@@ -66,7 +66,7 @@ struct ip_vs_dh_bucket {
66/* 66/*
67 * Returns hash value for IPVS DH entry 67 * Returns hash value for IPVS DH entry
68 */ 68 */
69static inline unsigned ip_vs_dh_hashkey(__u32 addr) 69static inline unsigned ip_vs_dh_hashkey(__be32 addr)
70{ 70{
71 return (ntohl(addr)*2654435761UL) & IP_VS_DH_TAB_MASK; 71 return (ntohl(addr)*2654435761UL) & IP_VS_DH_TAB_MASK;
72} 72}
@@ -76,7 +76,7 @@ static inline unsigned ip_vs_dh_hashkey(__u32 addr)
76 * Get ip_vs_dest associated with supplied parameters. 76 * Get ip_vs_dest associated with supplied parameters.
77 */ 77 */
78static inline struct ip_vs_dest * 78static inline struct ip_vs_dest *
79ip_vs_dh_get(struct ip_vs_dh_bucket *tbl, __u32 addr) 79ip_vs_dh_get(struct ip_vs_dh_bucket *tbl, __be32 addr)
80{ 80{
81 return (tbl[ip_vs_dh_hashkey(addr)]).dest; 81 return (tbl[ip_vs_dh_hashkey(addr)]).dest;
82} 82}
diff --git a/net/ipv4/ipvs/ip_vs_ftp.c b/net/ipv4/ipvs/ip_vs_ftp.c
index 37fafb1fbcff..e433cb0ff894 100644
--- a/net/ipv4/ipvs/ip_vs_ftp.c
+++ b/net/ipv4/ipvs/ip_vs_ftp.c
@@ -32,6 +32,7 @@
32#include <linux/ip.h> 32#include <linux/ip.h>
33#include <net/protocol.h> 33#include <net/protocol.h>
34#include <net/tcp.h> 34#include <net/tcp.h>
35#include <asm/unaligned.h>
35 36
36#include <net/ip_vs.h> 37#include <net/ip_vs.h>
37 38
@@ -44,8 +45,8 @@
44 * List of ports (up to IP_VS_APP_MAX_PORTS) to be handled by helper 45 * List of ports (up to IP_VS_APP_MAX_PORTS) to be handled by helper
45 * First port is set to the default port. 46 * First port is set to the default port.
46 */ 47 */
47static int ports[IP_VS_APP_MAX_PORTS] = {21, 0}; 48static unsigned short ports[IP_VS_APP_MAX_PORTS] = {21, 0};
48module_param_array(ports, int, NULL, 0); 49module_param_array(ports, ushort, NULL, 0);
49MODULE_PARM_DESC(ports, "Ports to monitor for FTP control commands"); 50MODULE_PARM_DESC(ports, "Ports to monitor for FTP control commands");
50 51
51 52
@@ -74,7 +75,7 @@ ip_vs_ftp_done_conn(struct ip_vs_app *app, struct ip_vs_conn *cp)
74 */ 75 */
75static int ip_vs_ftp_get_addrport(char *data, char *data_limit, 76static int ip_vs_ftp_get_addrport(char *data, char *data_limit,
76 const char *pattern, size_t plen, char term, 77 const char *pattern, size_t plen, char term,
77 __u32 *addr, __u16 *port, 78 __be32 *addr, __be16 *port,
78 char **start, char **end) 79 char **start, char **end)
79{ 80{
80 unsigned char p[6]; 81 unsigned char p[6];
@@ -114,8 +115,8 @@ static int ip_vs_ftp_get_addrport(char *data, char *data_limit,
114 if (i != 5) 115 if (i != 5)
115 return -1; 116 return -1;
116 117
117 *addr = (p[3]<<24) | (p[2]<<16) | (p[1]<<8) | p[0]; 118 *addr = get_unaligned((__be32 *)p);
118 *port = (p[5]<<8) | p[4]; 119 *port = get_unaligned((__be16 *)(p + 4));
119 return 1; 120 return 1;
120} 121}
121 122
@@ -140,8 +141,8 @@ static int ip_vs_ftp_out(struct ip_vs_app *app, struct ip_vs_conn *cp,
140 struct tcphdr *th; 141 struct tcphdr *th;
141 char *data, *data_limit; 142 char *data, *data_limit;
142 char *start, *end; 143 char *start, *end;
143 __u32 from; 144 __be32 from;
144 __u16 port; 145 __be16 port;
145 struct ip_vs_conn *n_cp; 146 struct ip_vs_conn *n_cp;
146 char buf[24]; /* xxx.xxx.xxx.xxx,ppp,ppp\000 */ 147 char buf[24]; /* xxx.xxx.xxx.xxx,ppp,ppp\000 */
147 unsigned buf_len; 148 unsigned buf_len;
@@ -199,7 +200,7 @@ static int ip_vs_ftp_out(struct ip_vs_app *app, struct ip_vs_conn *cp,
199 from = n_cp->vaddr; 200 from = n_cp->vaddr;
200 port = n_cp->vport; 201 port = n_cp->vport;
201 sprintf(buf,"%d,%d,%d,%d,%d,%d", NIPQUAD(from), 202 sprintf(buf,"%d,%d,%d,%d,%d,%d", NIPQUAD(from),
202 port&255, (port>>8)&255); 203 ntohs(port)&255, (ntohs(port)>>8)&255);
203 buf_len = strlen(buf); 204 buf_len = strlen(buf);
204 205
205 /* 206 /*
@@ -243,8 +244,8 @@ static int ip_vs_ftp_in(struct ip_vs_app *app, struct ip_vs_conn *cp,
243 struct tcphdr *th; 244 struct tcphdr *th;
244 char *data, *data_start, *data_limit; 245 char *data, *data_start, *data_limit;
245 char *start, *end; 246 char *start, *end;
246 __u32 to; 247 __be32 to;
247 __u16 port; 248 __be16 port;
248 struct ip_vs_conn *n_cp; 249 struct ip_vs_conn *n_cp;
249 250
250 /* no diff required for incoming packets */ 251 /* no diff required for incoming packets */
@@ -365,12 +366,6 @@ static int __init ip_vs_ftp_init(void)
365 for (i=0; i<IP_VS_APP_MAX_PORTS; i++) { 366 for (i=0; i<IP_VS_APP_MAX_PORTS; i++) {
366 if (!ports[i]) 367 if (!ports[i])
367 continue; 368 continue;
368 if (ports[i] < 0 || ports[i] > 0xffff) {
369 IP_VS_WARNING("ip_vs_ftp: Ignoring invalid "
370 "configuration port[%d] = %d\n",
371 i, ports[i]);
372 continue;
373 }
374 ret = register_ip_vs_app_inc(app, app->protocol, ports[i]); 369 ret = register_ip_vs_app_inc(app, app->protocol, ports[i]);
375 if (ret) 370 if (ret)
376 break; 371 break;
diff --git a/net/ipv4/ipvs/ip_vs_lblc.c b/net/ipv4/ipvs/ip_vs_lblc.c
index 6e5cb92a5c83..524751e031de 100644
--- a/net/ipv4/ipvs/ip_vs_lblc.c
+++ b/net/ipv4/ipvs/ip_vs_lblc.c
@@ -87,7 +87,7 @@ static int sysctl_ip_vs_lblc_expiration = 24*60*60*HZ;
87 */ 87 */
88struct ip_vs_lblc_entry { 88struct ip_vs_lblc_entry {
89 struct list_head list; 89 struct list_head list;
90 __u32 addr; /* destination IP address */ 90 __be32 addr; /* destination IP address */
91 struct ip_vs_dest *dest; /* real server (cache) */ 91 struct ip_vs_dest *dest; /* real server (cache) */
92 unsigned long lastuse; /* last used time */ 92 unsigned long lastuse; /* last used time */
93}; 93};
@@ -160,7 +160,7 @@ static struct ctl_table_header * sysctl_header;
160 * IP address to a server. 160 * IP address to a server.
161 */ 161 */
162static inline struct ip_vs_lblc_entry * 162static inline struct ip_vs_lblc_entry *
163ip_vs_lblc_new(__u32 daddr, struct ip_vs_dest *dest) 163ip_vs_lblc_new(__be32 daddr, struct ip_vs_dest *dest)
164{ 164{
165 struct ip_vs_lblc_entry *en; 165 struct ip_vs_lblc_entry *en;
166 166
@@ -195,7 +195,7 @@ static inline void ip_vs_lblc_free(struct ip_vs_lblc_entry *en)
195/* 195/*
196 * Returns hash value for IPVS LBLC entry 196 * Returns hash value for IPVS LBLC entry
197 */ 197 */
198static inline unsigned ip_vs_lblc_hashkey(__u32 addr) 198static inline unsigned ip_vs_lblc_hashkey(__be32 addr)
199{ 199{
200 return (ntohl(addr)*2654435761UL) & IP_VS_LBLC_TAB_MASK; 200 return (ntohl(addr)*2654435761UL) & IP_VS_LBLC_TAB_MASK;
201} 201}
@@ -234,7 +234,7 @@ ip_vs_lblc_hash(struct ip_vs_lblc_table *tbl, struct ip_vs_lblc_entry *en)
234 * Get ip_vs_lblc_entry associated with supplied parameters. 234 * Get ip_vs_lblc_entry associated with supplied parameters.
235 */ 235 */
236static inline struct ip_vs_lblc_entry * 236static inline struct ip_vs_lblc_entry *
237ip_vs_lblc_get(struct ip_vs_lblc_table *tbl, __u32 addr) 237ip_vs_lblc_get(struct ip_vs_lblc_table *tbl, __be32 addr)
238{ 238{
239 unsigned hash; 239 unsigned hash;
240 struct ip_vs_lblc_entry *en; 240 struct ip_vs_lblc_entry *en;
diff --git a/net/ipv4/ipvs/ip_vs_lblcr.c b/net/ipv4/ipvs/ip_vs_lblcr.c
index 32ba37ba72d8..08990192b6ec 100644
--- a/net/ipv4/ipvs/ip_vs_lblcr.c
+++ b/net/ipv4/ipvs/ip_vs_lblcr.c
@@ -276,7 +276,7 @@ static inline struct ip_vs_dest *ip_vs_dest_set_max(struct ip_vs_dest_set *set)
276 */ 276 */
277struct ip_vs_lblcr_entry { 277struct ip_vs_lblcr_entry {
278 struct list_head list; 278 struct list_head list;
279 __u32 addr; /* destination IP address */ 279 __be32 addr; /* destination IP address */
280 struct ip_vs_dest_set set; /* destination server set */ 280 struct ip_vs_dest_set set; /* destination server set */
281 unsigned long lastuse; /* last used time */ 281 unsigned long lastuse; /* last used time */
282}; 282};
@@ -348,7 +348,7 @@ static struct ctl_table_header * sysctl_header;
348 * new/free a ip_vs_lblcr_entry, which is a mapping of a destination 348 * new/free a ip_vs_lblcr_entry, which is a mapping of a destination
349 * IP address to a server. 349 * IP address to a server.
350 */ 350 */
351static inline struct ip_vs_lblcr_entry *ip_vs_lblcr_new(__u32 daddr) 351static inline struct ip_vs_lblcr_entry *ip_vs_lblcr_new(__be32 daddr)
352{ 352{
353 struct ip_vs_lblcr_entry *en; 353 struct ip_vs_lblcr_entry *en;
354 354
@@ -381,7 +381,7 @@ static inline void ip_vs_lblcr_free(struct ip_vs_lblcr_entry *en)
381/* 381/*
382 * Returns hash value for IPVS LBLCR entry 382 * Returns hash value for IPVS LBLCR entry
383 */ 383 */
384static inline unsigned ip_vs_lblcr_hashkey(__u32 addr) 384static inline unsigned ip_vs_lblcr_hashkey(__be32 addr)
385{ 385{
386 return (ntohl(addr)*2654435761UL) & IP_VS_LBLCR_TAB_MASK; 386 return (ntohl(addr)*2654435761UL) & IP_VS_LBLCR_TAB_MASK;
387} 387}
@@ -420,7 +420,7 @@ ip_vs_lblcr_hash(struct ip_vs_lblcr_table *tbl, struct ip_vs_lblcr_entry *en)
420 * Get ip_vs_lblcr_entry associated with supplied parameters. 420 * Get ip_vs_lblcr_entry associated with supplied parameters.
421 */ 421 */
422static inline struct ip_vs_lblcr_entry * 422static inline struct ip_vs_lblcr_entry *
423ip_vs_lblcr_get(struct ip_vs_lblcr_table *tbl, __u32 addr) 423ip_vs_lblcr_get(struct ip_vs_lblcr_table *tbl, __be32 addr)
424{ 424{
425 unsigned hash; 425 unsigned hash;
426 struct ip_vs_lblcr_entry *en; 426 struct ip_vs_lblcr_entry *en;
diff --git a/net/ipv4/ipvs/ip_vs_proto.c b/net/ipv4/ipvs/ip_vs_proto.c
index 867d4e9c6594..c4528b5c800d 100644
--- a/net/ipv4/ipvs/ip_vs_proto.c
+++ b/net/ipv4/ipvs/ip_vs_proto.c
@@ -176,7 +176,7 @@ ip_vs_tcpudp_debug_packet(struct ip_vs_protocol *pp,
176 pp->name, NIPQUAD(ih->saddr), 176 pp->name, NIPQUAD(ih->saddr),
177 NIPQUAD(ih->daddr)); 177 NIPQUAD(ih->daddr));
178 else { 178 else {
179 __u16 _ports[2], *pptr 179 __be16 _ports[2], *pptr
180; 180;
181 pptr = skb_header_pointer(skb, offset + ih->ihl*4, 181 pptr = skb_header_pointer(skb, offset + ih->ihl*4,
182 sizeof(_ports), _ports); 182 sizeof(_ports), _ports);
diff --git a/net/ipv4/ipvs/ip_vs_proto_tcp.c b/net/ipv4/ipvs/ip_vs_proto_tcp.c
index 820e8318d10d..bfe779e74590 100644
--- a/net/ipv4/ipvs/ip_vs_proto_tcp.c
+++ b/net/ipv4/ipvs/ip_vs_proto_tcp.c
@@ -29,7 +29,7 @@ static struct ip_vs_conn *
29tcp_conn_in_get(const struct sk_buff *skb, struct ip_vs_protocol *pp, 29tcp_conn_in_get(const struct sk_buff *skb, struct ip_vs_protocol *pp,
30 const struct iphdr *iph, unsigned int proto_off, int inverse) 30 const struct iphdr *iph, unsigned int proto_off, int inverse)
31{ 31{
32 __u16 _ports[2], *pptr; 32 __be16 _ports[2], *pptr;
33 33
34 pptr = skb_header_pointer(skb, proto_off, sizeof(_ports), _ports); 34 pptr = skb_header_pointer(skb, proto_off, sizeof(_ports), _ports);
35 if (pptr == NULL) 35 if (pptr == NULL)
@@ -50,7 +50,7 @@ static struct ip_vs_conn *
50tcp_conn_out_get(const struct sk_buff *skb, struct ip_vs_protocol *pp, 50tcp_conn_out_get(const struct sk_buff *skb, struct ip_vs_protocol *pp,
51 const struct iphdr *iph, unsigned int proto_off, int inverse) 51 const struct iphdr *iph, unsigned int proto_off, int inverse)
52{ 52{
53 __u16 _ports[2], *pptr; 53 __be16 _ports[2], *pptr;
54 54
55 pptr = skb_header_pointer(skb, proto_off, sizeof(_ports), _ports); 55 pptr = skb_header_pointer(skb, proto_off, sizeof(_ports), _ports);
56 if (pptr == NULL) 56 if (pptr == NULL)
@@ -112,12 +112,12 @@ tcp_conn_schedule(struct sk_buff *skb,
112 112
113 113
114static inline void 114static inline void
115tcp_fast_csum_update(struct tcphdr *tcph, u32 oldip, u32 newip, 115tcp_fast_csum_update(struct tcphdr *tcph, __be32 oldip, __be32 newip,
116 u16 oldport, u16 newport) 116 __be16 oldport, __be16 newport)
117{ 117{
118 tcph->check = 118 tcph->check =
119 ip_vs_check_diff(~oldip, newip, 119 ip_vs_check_diff(~oldip, newip,
120 ip_vs_check_diff(oldport ^ 0xFFFF, 120 ip_vs_check_diff(oldport ^ htonl(0xFFFF),
121 newport, tcph->check)); 121 newport, tcph->check));
122} 122}
123 123
diff --git a/net/ipv4/ipvs/ip_vs_proto_udp.c b/net/ipv4/ipvs/ip_vs_proto_udp.c
index 90c8166c0ec1..54aa7603591f 100644
--- a/net/ipv4/ipvs/ip_vs_proto_udp.c
+++ b/net/ipv4/ipvs/ip_vs_proto_udp.c
@@ -29,7 +29,7 @@ udp_conn_in_get(const struct sk_buff *skb, struct ip_vs_protocol *pp,
29 const struct iphdr *iph, unsigned int proto_off, int inverse) 29 const struct iphdr *iph, unsigned int proto_off, int inverse)
30{ 30{
31 struct ip_vs_conn *cp; 31 struct ip_vs_conn *cp;
32 __u16 _ports[2], *pptr; 32 __be16 _ports[2], *pptr;
33 33
34 pptr = skb_header_pointer(skb, proto_off, sizeof(_ports), _ports); 34 pptr = skb_header_pointer(skb, proto_off, sizeof(_ports), _ports);
35 if (pptr == NULL) 35 if (pptr == NULL)
@@ -54,7 +54,7 @@ udp_conn_out_get(const struct sk_buff *skb, struct ip_vs_protocol *pp,
54 const struct iphdr *iph, unsigned int proto_off, int inverse) 54 const struct iphdr *iph, unsigned int proto_off, int inverse)
55{ 55{
56 struct ip_vs_conn *cp; 56 struct ip_vs_conn *cp;
57 __u16 _ports[2], *pptr; 57 __be16 _ports[2], *pptr;
58 58
59 pptr = skb_header_pointer(skb, skb->nh.iph->ihl*4, 59 pptr = skb_header_pointer(skb, skb->nh.iph->ihl*4,
60 sizeof(_ports), _ports); 60 sizeof(_ports), _ports);
@@ -117,15 +117,15 @@ udp_conn_schedule(struct sk_buff *skb, struct ip_vs_protocol *pp,
117 117
118 118
119static inline void 119static inline void
120udp_fast_csum_update(struct udphdr *uhdr, u32 oldip, u32 newip, 120udp_fast_csum_update(struct udphdr *uhdr, __be32 oldip, __be32 newip,
121 u16 oldport, u16 newport) 121 __be16 oldport, __be16 newport)
122{ 122{
123 uhdr->check = 123 uhdr->check =
124 ip_vs_check_diff(~oldip, newip, 124 ip_vs_check_diff(~oldip, newip,
125 ip_vs_check_diff(oldport ^ 0xFFFF, 125 ip_vs_check_diff(oldport ^ htonl(0xFFFF),
126 newport, uhdr->check)); 126 newport, uhdr->check));
127 if (!uhdr->check) 127 if (!uhdr->check)
128 uhdr->check = 0xFFFF; 128 uhdr->check = htonl(0xFFFF);
129} 129}
130 130
131static int 131static int
@@ -173,7 +173,7 @@ udp_snat_handler(struct sk_buff **pskb,
173 cp->protocol, 173 cp->protocol,
174 (*pskb)->csum); 174 (*pskb)->csum);
175 if (udph->check == 0) 175 if (udph->check == 0)
176 udph->check = 0xFFFF; 176 udph->check = htonl(0xFFFF);
177 IP_VS_DBG(11, "O-pkt: %s O-csum=%d (+%zd)\n", 177 IP_VS_DBG(11, "O-pkt: %s O-csum=%d (+%zd)\n",
178 pp->name, udph->check, 178 pp->name, udph->check,
179 (char*)&(udph->check) - (char*)udph); 179 (char*)&(udph->check) - (char*)udph);
diff --git a/net/ipv4/ipvs/ip_vs_sh.c b/net/ipv4/ipvs/ip_vs_sh.c
index 7775e6cc68be..338668f88fe2 100644
--- a/net/ipv4/ipvs/ip_vs_sh.c
+++ b/net/ipv4/ipvs/ip_vs_sh.c
@@ -63,7 +63,7 @@ struct ip_vs_sh_bucket {
63/* 63/*
64 * Returns hash value for IPVS SH entry 64 * Returns hash value for IPVS SH entry
65 */ 65 */
66static inline unsigned ip_vs_sh_hashkey(__u32 addr) 66static inline unsigned ip_vs_sh_hashkey(__be32 addr)
67{ 67{
68 return (ntohl(addr)*2654435761UL) & IP_VS_SH_TAB_MASK; 68 return (ntohl(addr)*2654435761UL) & IP_VS_SH_TAB_MASK;
69} 69}
@@ -73,7 +73,7 @@ static inline unsigned ip_vs_sh_hashkey(__u32 addr)
73 * Get ip_vs_dest associated with supplied parameters. 73 * Get ip_vs_dest associated with supplied parameters.
74 */ 74 */
75static inline struct ip_vs_dest * 75static inline struct ip_vs_dest *
76ip_vs_sh_get(struct ip_vs_sh_bucket *tbl, __u32 addr) 76ip_vs_sh_get(struct ip_vs_sh_bucket *tbl, __be32 addr)
77{ 77{
78 return (tbl[ip_vs_sh_hashkey(addr)]).dest; 78 return (tbl[ip_vs_sh_hashkey(addr)]).dest;
79} 79}
diff --git a/net/ipv4/ipvs/ip_vs_sync.c b/net/ipv4/ipvs/ip_vs_sync.c
index 1bca714bda3d..6ab57d72b615 100644
--- a/net/ipv4/ipvs/ip_vs_sync.c
+++ b/net/ipv4/ipvs/ip_vs_sync.c
@@ -48,16 +48,16 @@ struct ip_vs_sync_conn {
48 48
49 /* Protocol, addresses and port numbers */ 49 /* Protocol, addresses and port numbers */
50 __u8 protocol; /* Which protocol (TCP/UDP) */ 50 __u8 protocol; /* Which protocol (TCP/UDP) */
51 __u16 cport; 51 __be16 cport;
52 __u16 vport; 52 __be16 vport;
53 __u16 dport; 53 __be16 dport;
54 __u32 caddr; /* client address */ 54 __be32 caddr; /* client address */
55 __u32 vaddr; /* virtual address */ 55 __be32 vaddr; /* virtual address */
56 __u32 daddr; /* destination address */ 56 __be32 daddr; /* destination address */
57 57
58 /* Flags and state transition */ 58 /* Flags and state transition */
59 __u16 flags; /* status flags */ 59 __be16 flags; /* status flags */
60 __u16 state; /* state info */ 60 __be16 state; /* state info */
61 61
62 /* The sequence options start here */ 62 /* The sequence options start here */
63}; 63};
@@ -464,7 +464,7 @@ join_mcast_group(struct sock *sk, struct in_addr *addr, char *ifname)
464static int bind_mcastif_addr(struct socket *sock, char *ifname) 464static int bind_mcastif_addr(struct socket *sock, char *ifname)
465{ 465{
466 struct net_device *dev; 466 struct net_device *dev;
467 u32 addr; 467 __be32 addr;
468 struct sockaddr_in sin; 468 struct sockaddr_in sin;
469 469
470 if ((dev = __dev_get_by_name(ifname)) == NULL) 470 if ((dev = __dev_get_by_name(ifname)) == NULL)
diff --git a/net/ipv4/ipvs/ip_vs_xmit.c b/net/ipv4/ipvs/ip_vs_xmit.c
index 52c12e9edbbc..e1f77bd7c9a5 100644
--- a/net/ipv4/ipvs/ip_vs_xmit.c
+++ b/net/ipv4/ipvs/ip_vs_xmit.c
@@ -232,7 +232,7 @@ ip_vs_nat_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,
232 232
233 /* check if it is a connection of no-client-port */ 233 /* check if it is a connection of no-client-port */
234 if (unlikely(cp->flags & IP_VS_CONN_F_NO_CPORT)) { 234 if (unlikely(cp->flags & IP_VS_CONN_F_NO_CPORT)) {
235 __u16 _pt, *p; 235 __be16 _pt, *p;
236 p = skb_header_pointer(skb, iph->ihl*4, sizeof(_pt), &_pt); 236 p = skb_header_pointer(skb, iph->ihl*4, sizeof(_pt), &_pt);
237 if (p == NULL) 237 if (p == NULL)
238 goto tx_error; 238 goto tx_error;
diff --git a/net/ipv4/multipath_wrandom.c b/net/ipv4/multipath_wrandom.c
index d25ec4ae09e5..92b04823e034 100644
--- a/net/ipv4/multipath_wrandom.c
+++ b/net/ipv4/multipath_wrandom.c
@@ -60,8 +60,8 @@ struct multipath_dest {
60 struct list_head list; 60 struct list_head list;
61 61
62 const struct fib_nh *nh_info; 62 const struct fib_nh *nh_info;
63 __u32 netmask; 63 __be32 netmask;
64 __u32 network; 64 __be32 network;
65 unsigned char prefixlen; 65 unsigned char prefixlen;
66 66
67 struct rcu_head rcu; 67 struct rcu_head rcu;
@@ -76,7 +76,7 @@ struct multipath_route {
76 struct list_head list; 76 struct list_head list;
77 77
78 int oif; 78 int oif;
79 __u32 gw; 79 __be32 gw;
80 struct list_head dests; 80 struct list_head dests;
81 81
82 struct rcu_head rcu; 82 struct rcu_head rcu;
@@ -128,8 +128,8 @@ static unsigned char __multipath_lookup_weight(const struct flowi *fl,
128 128
129 /* find state entry for destination */ 129 /* find state entry for destination */
130 list_for_each_entry_rcu(d, &target_route->dests, list) { 130 list_for_each_entry_rcu(d, &target_route->dests, list) {
131 __u32 targetnetwork = fl->fl4_dst & 131 __be32 targetnetwork = fl->fl4_dst &
132 (0xFFFFFFFF >> (32 - d->prefixlen)); 132 inet_make_mask(d->prefixlen);
133 133
134 if ((targetnetwork & d->netmask) == d->network) { 134 if ((targetnetwork & d->netmask) == d->network) {
135 weight = d->nh_info->nh_weight; 135 weight = d->nh_info->nh_weight;
@@ -217,8 +217,8 @@ static void wrandom_select_route(const struct flowi *flp,
217 *rp = decision; 217 *rp = decision;
218} 218}
219 219
220static void wrandom_set_nhinfo(__u32 network, 220static void wrandom_set_nhinfo(__be32 network,
221 __u32 netmask, 221 __be32 netmask,
222 unsigned char prefixlen, 222 unsigned char prefixlen,
223 const struct fib_nh *nh) 223 const struct fib_nh *nh)
224{ 224{
diff --git a/net/ipv4/netfilter.c b/net/ipv4/netfilter.c
index f88347de21a9..5ac15379a0cf 100644
--- a/net/ipv4/netfilter.c
+++ b/net/ipv4/netfilter.c
@@ -128,8 +128,8 @@ EXPORT_SYMBOL(ip_nat_decode_session);
128 */ 128 */
129 129
130struct ip_rt_info { 130struct ip_rt_info {
131 u_int32_t daddr; 131 __be32 daddr;
132 u_int32_t saddr; 132 __be32 saddr;
133 u_int8_t tos; 133 u_int8_t tos;
134}; 134};
135 135
diff --git a/net/ipv4/netfilter/arp_tables.c b/net/ipv4/netfilter/arp_tables.c
index 85f0d73ebfb4..17e1a687ab45 100644
--- a/net/ipv4/netfilter/arp_tables.c
+++ b/net/ipv4/netfilter/arp_tables.c
@@ -80,7 +80,7 @@ static inline int arp_packet_match(const struct arphdr *arphdr,
80{ 80{
81 char *arpptr = (char *)(arphdr + 1); 81 char *arpptr = (char *)(arphdr + 1);
82 char *src_devaddr, *tgt_devaddr; 82 char *src_devaddr, *tgt_devaddr;
83 u32 src_ipaddr, tgt_ipaddr; 83 __be32 src_ipaddr, tgt_ipaddr;
84 int i, ret; 84 int i, ret;
85 85
86#define FWINV(bool,invflg) ((bool) ^ !!(arpinfo->invflags & invflg)) 86#define FWINV(bool,invflg) ((bool) ^ !!(arpinfo->invflags & invflg))
diff --git a/net/ipv4/netfilter/ip_conntrack_amanda.c b/net/ipv4/netfilter/ip_conntrack_amanda.c
index 0a7bd7f04061..6c7383a8e42b 100644
--- a/net/ipv4/netfilter/ip_conntrack_amanda.c
+++ b/net/ipv4/netfilter/ip_conntrack_amanda.c
@@ -155,11 +155,11 @@ static int help(struct sk_buff **pskb,
155 exp->tuple.dst.protonum = IPPROTO_TCP; 155 exp->tuple.dst.protonum = IPPROTO_TCP;
156 exp->tuple.dst.u.tcp.port = htons(port); 156 exp->tuple.dst.u.tcp.port = htons(port);
157 157
158 exp->mask.src.ip = 0xFFFFFFFF; 158 exp->mask.src.ip = htonl(0xFFFFFFFF);
159 exp->mask.src.u.tcp.port = 0; 159 exp->mask.src.u.tcp.port = 0;
160 exp->mask.dst.ip = 0xFFFFFFFF; 160 exp->mask.dst.ip = htonl(0xFFFFFFFF);
161 exp->mask.dst.protonum = 0xFF; 161 exp->mask.dst.protonum = 0xFF;
162 exp->mask.dst.u.tcp.port = 0xFFFF; 162 exp->mask.dst.u.tcp.port = htons(0xFFFF);
163 163
164 if (ip_nat_amanda_hook) 164 if (ip_nat_amanda_hook)
165 ret = ip_nat_amanda_hook(pskb, ctinfo, off - dataoff, 165 ret = ip_nat_amanda_hook(pskb, ctinfo, off - dataoff,
diff --git a/net/ipv4/netfilter/ip_conntrack_core.c b/net/ipv4/netfilter/ip_conntrack_core.c
index c432b3163609..143c4668538b 100644
--- a/net/ipv4/netfilter/ip_conntrack_core.c
+++ b/net/ipv4/netfilter/ip_conntrack_core.c
@@ -149,8 +149,8 @@ static unsigned int ip_conntrack_hash_rnd;
149static u_int32_t __hash_conntrack(const struct ip_conntrack_tuple *tuple, 149static u_int32_t __hash_conntrack(const struct ip_conntrack_tuple *tuple,
150 unsigned int size, unsigned int rnd) 150 unsigned int size, unsigned int rnd)
151{ 151{
152 return (jhash_3words(tuple->src.ip, 152 return (jhash_3words((__force u32)tuple->src.ip,
153 (tuple->dst.ip ^ tuple->dst.protonum), 153 ((__force u32)tuple->dst.ip ^ tuple->dst.protonum),
154 (tuple->src.u.all | (tuple->dst.u.all << 16)), 154 (tuple->src.u.all | (tuple->dst.u.all << 16)),
155 rnd) % size); 155 rnd) % size);
156} 156}
@@ -1169,9 +1169,9 @@ void __ip_ct_refresh_acct(struct ip_conntrack *ct,
1169int ip_ct_port_tuple_to_nfattr(struct sk_buff *skb, 1169int ip_ct_port_tuple_to_nfattr(struct sk_buff *skb,
1170 const struct ip_conntrack_tuple *tuple) 1170 const struct ip_conntrack_tuple *tuple)
1171{ 1171{
1172 NFA_PUT(skb, CTA_PROTO_SRC_PORT, sizeof(u_int16_t), 1172 NFA_PUT(skb, CTA_PROTO_SRC_PORT, sizeof(__be16),
1173 &tuple->src.u.tcp.port); 1173 &tuple->src.u.tcp.port);
1174 NFA_PUT(skb, CTA_PROTO_DST_PORT, sizeof(u_int16_t), 1174 NFA_PUT(skb, CTA_PROTO_DST_PORT, sizeof(__be16),
1175 &tuple->dst.u.tcp.port); 1175 &tuple->dst.u.tcp.port);
1176 return 0; 1176 return 0;
1177 1177
@@ -1186,9 +1186,9 @@ int ip_ct_port_nfattr_to_tuple(struct nfattr *tb[],
1186 return -EINVAL; 1186 return -EINVAL;
1187 1187
1188 t->src.u.tcp.port = 1188 t->src.u.tcp.port =
1189 *(u_int16_t *)NFA_DATA(tb[CTA_PROTO_SRC_PORT-1]); 1189 *(__be16 *)NFA_DATA(tb[CTA_PROTO_SRC_PORT-1]);
1190 t->dst.u.tcp.port = 1190 t->dst.u.tcp.port =
1191 *(u_int16_t *)NFA_DATA(tb[CTA_PROTO_DST_PORT-1]); 1191 *(__be16 *)NFA_DATA(tb[CTA_PROTO_DST_PORT-1]);
1192 1192
1193 return 0; 1193 return 0;
1194} 1194}
diff --git a/net/ipv4/netfilter/ip_conntrack_ftp.c b/net/ipv4/netfilter/ip_conntrack_ftp.c
index 1d18c863f064..93dcf960662f 100644
--- a/net/ipv4/netfilter/ip_conntrack_ftp.c
+++ b/net/ipv4/netfilter/ip_conntrack_ftp.c
@@ -425,8 +425,8 @@ static int help(struct sk_buff **pskb,
425 exp->tuple.src.u.tcp.port = 0; /* Don't care. */ 425 exp->tuple.src.u.tcp.port = 0; /* Don't care. */
426 exp->tuple.dst.protonum = IPPROTO_TCP; 426 exp->tuple.dst.protonum = IPPROTO_TCP;
427 exp->mask = ((struct ip_conntrack_tuple) 427 exp->mask = ((struct ip_conntrack_tuple)
428 { { 0xFFFFFFFF, { 0 } }, 428 { { htonl(0xFFFFFFFF), { 0 } },
429 { 0xFFFFFFFF, { .tcp = { 0xFFFF } }, 0xFF }}); 429 { htonl(0xFFFFFFFF), { .tcp = { htons(0xFFFF) } }, 0xFF }});
430 430
431 exp->expectfn = NULL; 431 exp->expectfn = NULL;
432 exp->flags = 0; 432 exp->flags = 0;
@@ -488,7 +488,7 @@ static int __init ip_conntrack_ftp_init(void)
488 for (i = 0; i < ports_c; i++) { 488 for (i = 0; i < ports_c; i++) {
489 ftp[i].tuple.src.u.tcp.port = htons(ports[i]); 489 ftp[i].tuple.src.u.tcp.port = htons(ports[i]);
490 ftp[i].tuple.dst.protonum = IPPROTO_TCP; 490 ftp[i].tuple.dst.protonum = IPPROTO_TCP;
491 ftp[i].mask.src.u.tcp.port = 0xFFFF; 491 ftp[i].mask.src.u.tcp.port = htons(0xFFFF);
492 ftp[i].mask.dst.protonum = 0xFF; 492 ftp[i].mask.dst.protonum = 0xFF;
493 ftp[i].max_expected = 1; 493 ftp[i].max_expected = 1;
494 ftp[i].timeout = 5 * 60; /* 5 minutes */ 494 ftp[i].timeout = 5 * 60; /* 5 minutes */
diff --git a/net/ipv4/netfilter/ip_conntrack_helper_h323.c b/net/ipv4/netfilter/ip_conntrack_helper_h323.c
index 9a39e2969712..7b7441202bfd 100644
--- a/net/ipv4/netfilter/ip_conntrack_helper_h323.c
+++ b/net/ipv4/netfilter/ip_conntrack_helper_h323.c
@@ -49,11 +49,11 @@ MODULE_PARM_DESC(callforward_filter, "only create call forwarding expectations "
49int (*set_h245_addr_hook) (struct sk_buff ** pskb, 49int (*set_h245_addr_hook) (struct sk_buff ** pskb,
50 unsigned char **data, int dataoff, 50 unsigned char **data, int dataoff,
51 H245_TransportAddress * addr, 51 H245_TransportAddress * addr,
52 u_int32_t ip, u_int16_t port); 52 __be32 ip, u_int16_t port);
53int (*set_h225_addr_hook) (struct sk_buff ** pskb, 53int (*set_h225_addr_hook) (struct sk_buff ** pskb,
54 unsigned char **data, int dataoff, 54 unsigned char **data, int dataoff,
55 TransportAddress * addr, 55 TransportAddress * addr,
56 u_int32_t ip, u_int16_t port); 56 __be32 ip, u_int16_t port);
57int (*set_sig_addr_hook) (struct sk_buff ** pskb, 57int (*set_sig_addr_hook) (struct sk_buff ** pskb,
58 struct ip_conntrack * ct, 58 struct ip_conntrack * ct,
59 enum ip_conntrack_info ctinfo, 59 enum ip_conntrack_info ctinfo,
@@ -209,7 +209,7 @@ static int get_tpkt_data(struct sk_buff **pskb, struct ip_conntrack *ct,
209 209
210/****************************************************************************/ 210/****************************************************************************/
211static int get_h245_addr(unsigned char *data, H245_TransportAddress * addr, 211static int get_h245_addr(unsigned char *data, H245_TransportAddress * addr,
212 u_int32_t * ip, u_int16_t * port) 212 __be32 * ip, u_int16_t * port)
213{ 213{
214 unsigned char *p; 214 unsigned char *p;
215 215
@@ -232,7 +232,7 @@ static int expect_rtp_rtcp(struct sk_buff **pskb, struct ip_conntrack *ct,
232{ 232{
233 int dir = CTINFO2DIR(ctinfo); 233 int dir = CTINFO2DIR(ctinfo);
234 int ret = 0; 234 int ret = 0;
235 u_int32_t ip; 235 __be32 ip;
236 u_int16_t port; 236 u_int16_t port;
237 u_int16_t rtp_port; 237 u_int16_t rtp_port;
238 struct ip_conntrack_expect *rtp_exp; 238 struct ip_conntrack_expect *rtp_exp;
@@ -254,10 +254,10 @@ static int expect_rtp_rtcp(struct sk_buff **pskb, struct ip_conntrack *ct,
254 rtp_exp->tuple.dst.ip = ct->tuplehash[!dir].tuple.dst.ip; 254 rtp_exp->tuple.dst.ip = ct->tuplehash[!dir].tuple.dst.ip;
255 rtp_exp->tuple.dst.u.udp.port = htons(rtp_port); 255 rtp_exp->tuple.dst.u.udp.port = htons(rtp_port);
256 rtp_exp->tuple.dst.protonum = IPPROTO_UDP; 256 rtp_exp->tuple.dst.protonum = IPPROTO_UDP;
257 rtp_exp->mask.src.ip = 0xFFFFFFFF; 257 rtp_exp->mask.src.ip = htonl(0xFFFFFFFF);
258 rtp_exp->mask.src.u.udp.port = 0; 258 rtp_exp->mask.src.u.udp.port = 0;
259 rtp_exp->mask.dst.ip = 0xFFFFFFFF; 259 rtp_exp->mask.dst.ip = htonl(0xFFFFFFFF);
260 rtp_exp->mask.dst.u.udp.port = 0xFFFF; 260 rtp_exp->mask.dst.u.udp.port = htons(0xFFFF);
261 rtp_exp->mask.dst.protonum = 0xFF; 261 rtp_exp->mask.dst.protonum = 0xFF;
262 rtp_exp->flags = 0; 262 rtp_exp->flags = 0;
263 263
@@ -271,10 +271,10 @@ static int expect_rtp_rtcp(struct sk_buff **pskb, struct ip_conntrack *ct,
271 rtcp_exp->tuple.dst.ip = ct->tuplehash[!dir].tuple.dst.ip; 271 rtcp_exp->tuple.dst.ip = ct->tuplehash[!dir].tuple.dst.ip;
272 rtcp_exp->tuple.dst.u.udp.port = htons(rtp_port + 1); 272 rtcp_exp->tuple.dst.u.udp.port = htons(rtp_port + 1);
273 rtcp_exp->tuple.dst.protonum = IPPROTO_UDP; 273 rtcp_exp->tuple.dst.protonum = IPPROTO_UDP;
274 rtcp_exp->mask.src.ip = 0xFFFFFFFF; 274 rtcp_exp->mask.src.ip = htonl(0xFFFFFFFF);
275 rtcp_exp->mask.src.u.udp.port = 0; 275 rtcp_exp->mask.src.u.udp.port = 0;
276 rtcp_exp->mask.dst.ip = 0xFFFFFFFF; 276 rtcp_exp->mask.dst.ip = htonl(0xFFFFFFFF);
277 rtcp_exp->mask.dst.u.udp.port = 0xFFFF; 277 rtcp_exp->mask.dst.u.udp.port = htons(0xFFFF);
278 rtcp_exp->mask.dst.protonum = 0xFF; 278 rtcp_exp->mask.dst.protonum = 0xFF;
279 rtcp_exp->flags = 0; 279 rtcp_exp->flags = 0;
280 280
@@ -325,7 +325,7 @@ static int expect_t120(struct sk_buff **pskb,
325{ 325{
326 int dir = CTINFO2DIR(ctinfo); 326 int dir = CTINFO2DIR(ctinfo);
327 int ret = 0; 327 int ret = 0;
328 u_int32_t ip; 328 __be32 ip;
329 u_int16_t port; 329 u_int16_t port;
330 struct ip_conntrack_expect *exp = NULL; 330 struct ip_conntrack_expect *exp = NULL;
331 331
@@ -342,10 +342,10 @@ static int expect_t120(struct sk_buff **pskb,
342 exp->tuple.dst.ip = ct->tuplehash[!dir].tuple.dst.ip; 342 exp->tuple.dst.ip = ct->tuplehash[!dir].tuple.dst.ip;
343 exp->tuple.dst.u.tcp.port = htons(port); 343 exp->tuple.dst.u.tcp.port = htons(port);
344 exp->tuple.dst.protonum = IPPROTO_TCP; 344 exp->tuple.dst.protonum = IPPROTO_TCP;
345 exp->mask.src.ip = 0xFFFFFFFF; 345 exp->mask.src.ip = htonl(0xFFFFFFFF);
346 exp->mask.src.u.tcp.port = 0; 346 exp->mask.src.u.tcp.port = 0;
347 exp->mask.dst.ip = 0xFFFFFFFF; 347 exp->mask.dst.ip = htonl(0xFFFFFFFF);
348 exp->mask.dst.u.tcp.port = 0xFFFF; 348 exp->mask.dst.u.tcp.port = htons(0xFFFF);
349 exp->mask.dst.protonum = 0xFF; 349 exp->mask.dst.protonum = 0xFF;
350 exp->flags = IP_CT_EXPECT_PERMANENT; /* Accept multiple channels */ 350 exp->flags = IP_CT_EXPECT_PERMANENT; /* Accept multiple channels */
351 351
@@ -626,7 +626,7 @@ void ip_conntrack_h245_expect(struct ip_conntrack *new,
626 626
627/****************************************************************************/ 627/****************************************************************************/
628int get_h225_addr(unsigned char *data, TransportAddress * addr, 628int get_h225_addr(unsigned char *data, TransportAddress * addr,
629 u_int32_t * ip, u_int16_t * port) 629 __be32 * ip, u_int16_t * port)
630{ 630{
631 unsigned char *p; 631 unsigned char *p;
632 632
@@ -648,7 +648,7 @@ static int expect_h245(struct sk_buff **pskb, struct ip_conntrack *ct,
648{ 648{
649 int dir = CTINFO2DIR(ctinfo); 649 int dir = CTINFO2DIR(ctinfo);
650 int ret = 0; 650 int ret = 0;
651 u_int32_t ip; 651 __be32 ip;
652 u_int16_t port; 652 u_int16_t port;
653 struct ip_conntrack_expect *exp = NULL; 653 struct ip_conntrack_expect *exp = NULL;
654 654
@@ -665,10 +665,10 @@ static int expect_h245(struct sk_buff **pskb, struct ip_conntrack *ct,
665 exp->tuple.dst.ip = ct->tuplehash[!dir].tuple.dst.ip; 665 exp->tuple.dst.ip = ct->tuplehash[!dir].tuple.dst.ip;
666 exp->tuple.dst.u.tcp.port = htons(port); 666 exp->tuple.dst.u.tcp.port = htons(port);
667 exp->tuple.dst.protonum = IPPROTO_TCP; 667 exp->tuple.dst.protonum = IPPROTO_TCP;
668 exp->mask.src.ip = 0xFFFFFFFF; 668 exp->mask.src.ip = htonl(0xFFFFFFFF);
669 exp->mask.src.u.tcp.port = 0; 669 exp->mask.src.u.tcp.port = 0;
670 exp->mask.dst.ip = 0xFFFFFFFF; 670 exp->mask.dst.ip = htonl(0xFFFFFFFF);
671 exp->mask.dst.u.tcp.port = 0xFFFF; 671 exp->mask.dst.u.tcp.port = htons(0xFFFF);
672 exp->mask.dst.protonum = 0xFF; 672 exp->mask.dst.protonum = 0xFF;
673 exp->flags = 0; 673 exp->flags = 0;
674 674
@@ -709,7 +709,7 @@ static int expect_callforwarding(struct sk_buff **pskb,
709{ 709{
710 int dir = CTINFO2DIR(ctinfo); 710 int dir = CTINFO2DIR(ctinfo);
711 int ret = 0; 711 int ret = 0;
712 u_int32_t ip; 712 __be32 ip;
713 u_int16_t port; 713 u_int16_t port;
714 struct ip_conntrack_expect *exp = NULL; 714 struct ip_conntrack_expect *exp = NULL;
715 715
@@ -751,10 +751,10 @@ static int expect_callforwarding(struct sk_buff **pskb,
751 exp->tuple.dst.ip = ip; 751 exp->tuple.dst.ip = ip;
752 exp->tuple.dst.u.tcp.port = htons(port); 752 exp->tuple.dst.u.tcp.port = htons(port);
753 exp->tuple.dst.protonum = IPPROTO_TCP; 753 exp->tuple.dst.protonum = IPPROTO_TCP;
754 exp->mask.src.ip = 0xFFFFFFFF; 754 exp->mask.src.ip = htonl(0xFFFFFFFF);
755 exp->mask.src.u.tcp.port = 0; 755 exp->mask.src.u.tcp.port = 0;
756 exp->mask.dst.ip = 0xFFFFFFFF; 756 exp->mask.dst.ip = htonl(0xFFFFFFFF);
757 exp->mask.dst.u.tcp.port = 0xFFFF; 757 exp->mask.dst.u.tcp.port = htons(0xFFFF);
758 exp->mask.dst.protonum = 0xFF; 758 exp->mask.dst.protonum = 0xFF;
759 exp->flags = 0; 759 exp->flags = 0;
760 760
@@ -791,7 +791,7 @@ static int process_setup(struct sk_buff **pskb, struct ip_conntrack *ct,
791 int dir = CTINFO2DIR(ctinfo); 791 int dir = CTINFO2DIR(ctinfo);
792 int ret; 792 int ret;
793 int i; 793 int i;
794 u_int32_t ip; 794 __be32 ip;
795 u_int16_t port; 795 u_int16_t port;
796 796
797 DEBUGP("ip_ct_q931: Setup\n"); 797 DEBUGP("ip_ct_q931: Setup\n");
@@ -1188,7 +1188,7 @@ static unsigned char *get_udp_data(struct sk_buff **pskb, int *datalen)
1188 1188
1189/****************************************************************************/ 1189/****************************************************************************/
1190static struct ip_conntrack_expect *find_expect(struct ip_conntrack *ct, 1190static struct ip_conntrack_expect *find_expect(struct ip_conntrack *ct,
1191 u_int32_t ip, u_int16_t port) 1191 __be32 ip, u_int16_t port)
1192{ 1192{
1193 struct ip_conntrack_expect *exp; 1193 struct ip_conntrack_expect *exp;
1194 struct ip_conntrack_tuple tuple; 1194 struct ip_conntrack_tuple tuple;
@@ -1228,7 +1228,7 @@ static int expect_q931(struct sk_buff **pskb, struct ip_conntrack *ct,
1228 int dir = CTINFO2DIR(ctinfo); 1228 int dir = CTINFO2DIR(ctinfo);
1229 int ret = 0; 1229 int ret = 0;
1230 int i; 1230 int i;
1231 u_int32_t ip; 1231 __be32 ip;
1232 u_int16_t port; 1232 u_int16_t port;
1233 struct ip_conntrack_expect *exp; 1233 struct ip_conntrack_expect *exp;
1234 1234
@@ -1251,10 +1251,10 @@ static int expect_q931(struct sk_buff **pskb, struct ip_conntrack *ct,
1251 exp->tuple.dst.ip = ct->tuplehash[!dir].tuple.dst.ip; 1251 exp->tuple.dst.ip = ct->tuplehash[!dir].tuple.dst.ip;
1252 exp->tuple.dst.u.tcp.port = htons(port); 1252 exp->tuple.dst.u.tcp.port = htons(port);
1253 exp->tuple.dst.protonum = IPPROTO_TCP; 1253 exp->tuple.dst.protonum = IPPROTO_TCP;
1254 exp->mask.src.ip = gkrouted_only ? 0xFFFFFFFF : 0; 1254 exp->mask.src.ip = gkrouted_only ? htonl(0xFFFFFFFF) : 0;
1255 exp->mask.src.u.tcp.port = 0; 1255 exp->mask.src.u.tcp.port = 0;
1256 exp->mask.dst.ip = 0xFFFFFFFF; 1256 exp->mask.dst.ip = htonl(0xFFFFFFFF);
1257 exp->mask.dst.u.tcp.port = 0xFFFF; 1257 exp->mask.dst.u.tcp.port = htons(0xFFFF);
1258 exp->mask.dst.protonum = 0xFF; 1258 exp->mask.dst.protonum = 0xFF;
1259 exp->flags = IP_CT_EXPECT_PERMANENT; /* Accept multiple calls */ 1259 exp->flags = IP_CT_EXPECT_PERMANENT; /* Accept multiple calls */
1260 1260
@@ -1307,7 +1307,7 @@ static int process_gcf(struct sk_buff **pskb, struct ip_conntrack *ct,
1307{ 1307{
1308 int dir = CTINFO2DIR(ctinfo); 1308 int dir = CTINFO2DIR(ctinfo);
1309 int ret = 0; 1309 int ret = 0;
1310 u_int32_t ip; 1310 __be32 ip;
1311 u_int16_t port; 1311 u_int16_t port;
1312 struct ip_conntrack_expect *exp; 1312 struct ip_conntrack_expect *exp;
1313 1313
@@ -1333,10 +1333,10 @@ static int process_gcf(struct sk_buff **pskb, struct ip_conntrack *ct,
1333 exp->tuple.dst.ip = ip; 1333 exp->tuple.dst.ip = ip;
1334 exp->tuple.dst.u.tcp.port = htons(port); 1334 exp->tuple.dst.u.tcp.port = htons(port);
1335 exp->tuple.dst.protonum = IPPROTO_UDP; 1335 exp->tuple.dst.protonum = IPPROTO_UDP;
1336 exp->mask.src.ip = 0xFFFFFFFF; 1336 exp->mask.src.ip = htonl(0xFFFFFFFF);
1337 exp->mask.src.u.tcp.port = 0; 1337 exp->mask.src.u.tcp.port = 0;
1338 exp->mask.dst.ip = 0xFFFFFFFF; 1338 exp->mask.dst.ip = htonl(0xFFFFFFFF);
1339 exp->mask.dst.u.tcp.port = 0xFFFF; 1339 exp->mask.dst.u.tcp.port = htons(0xFFFF);
1340 exp->mask.dst.protonum = 0xFF; 1340 exp->mask.dst.protonum = 0xFF;
1341 exp->flags = 0; 1341 exp->flags = 0;
1342 exp->expectfn = ip_conntrack_ras_expect; 1342 exp->expectfn = ip_conntrack_ras_expect;
@@ -1477,7 +1477,7 @@ static int process_arq(struct sk_buff **pskb, struct ip_conntrack *ct,
1477{ 1477{
1478 struct ip_ct_h323_master *info = &ct->help.ct_h323_info; 1478 struct ip_ct_h323_master *info = &ct->help.ct_h323_info;
1479 int dir = CTINFO2DIR(ctinfo); 1479 int dir = CTINFO2DIR(ctinfo);
1480 u_int32_t ip; 1480 __be32 ip;
1481 u_int16_t port; 1481 u_int16_t port;
1482 1482
1483 DEBUGP("ip_ct_ras: ARQ\n"); 1483 DEBUGP("ip_ct_ras: ARQ\n");
@@ -1513,7 +1513,7 @@ static int process_acf(struct sk_buff **pskb, struct ip_conntrack *ct,
1513{ 1513{
1514 int dir = CTINFO2DIR(ctinfo); 1514 int dir = CTINFO2DIR(ctinfo);
1515 int ret = 0; 1515 int ret = 0;
1516 u_int32_t ip; 1516 __be32 ip;
1517 u_int16_t port; 1517 u_int16_t port;
1518 struct ip_conntrack_expect *exp; 1518 struct ip_conntrack_expect *exp;
1519 1519
@@ -1538,10 +1538,10 @@ static int process_acf(struct sk_buff **pskb, struct ip_conntrack *ct,
1538 exp->tuple.dst.ip = ip; 1538 exp->tuple.dst.ip = ip;
1539 exp->tuple.dst.u.tcp.port = htons(port); 1539 exp->tuple.dst.u.tcp.port = htons(port);
1540 exp->tuple.dst.protonum = IPPROTO_TCP; 1540 exp->tuple.dst.protonum = IPPROTO_TCP;
1541 exp->mask.src.ip = 0xFFFFFFFF; 1541 exp->mask.src.ip = htonl(0xFFFFFFFF);
1542 exp->mask.src.u.tcp.port = 0; 1542 exp->mask.src.u.tcp.port = 0;
1543 exp->mask.dst.ip = 0xFFFFFFFF; 1543 exp->mask.dst.ip = htonl(0xFFFFFFFF);
1544 exp->mask.dst.u.tcp.port = 0xFFFF; 1544 exp->mask.dst.u.tcp.port = htons(0xFFFF);
1545 exp->mask.dst.protonum = 0xFF; 1545 exp->mask.dst.protonum = 0xFF;
1546 exp->flags = IP_CT_EXPECT_PERMANENT; 1546 exp->flags = IP_CT_EXPECT_PERMANENT;
1547 exp->expectfn = ip_conntrack_q931_expect; 1547 exp->expectfn = ip_conntrack_q931_expect;
@@ -1581,7 +1581,7 @@ static int process_lcf(struct sk_buff **pskb, struct ip_conntrack *ct,
1581{ 1581{
1582 int dir = CTINFO2DIR(ctinfo); 1582 int dir = CTINFO2DIR(ctinfo);
1583 int ret = 0; 1583 int ret = 0;
1584 u_int32_t ip; 1584 __be32 ip;
1585 u_int16_t port; 1585 u_int16_t port;
1586 struct ip_conntrack_expect *exp = NULL; 1586 struct ip_conntrack_expect *exp = NULL;
1587 1587
@@ -1598,10 +1598,10 @@ static int process_lcf(struct sk_buff **pskb, struct ip_conntrack *ct,
1598 exp->tuple.dst.ip = ip; 1598 exp->tuple.dst.ip = ip;
1599 exp->tuple.dst.u.tcp.port = htons(port); 1599 exp->tuple.dst.u.tcp.port = htons(port);
1600 exp->tuple.dst.protonum = IPPROTO_TCP; 1600 exp->tuple.dst.protonum = IPPROTO_TCP;
1601 exp->mask.src.ip = 0xFFFFFFFF; 1601 exp->mask.src.ip = htonl(0xFFFFFFFF);
1602 exp->mask.src.u.tcp.port = 0; 1602 exp->mask.src.u.tcp.port = 0;
1603 exp->mask.dst.ip = 0xFFFFFFFF; 1603 exp->mask.dst.ip = htonl(0xFFFFFFFF);
1604 exp->mask.dst.u.tcp.port = 0xFFFF; 1604 exp->mask.dst.u.tcp.port = htons(0xFFFF);
1605 exp->mask.dst.protonum = 0xFF; 1605 exp->mask.dst.protonum = 0xFF;
1606 exp->flags = IP_CT_EXPECT_PERMANENT; 1606 exp->flags = IP_CT_EXPECT_PERMANENT;
1607 exp->expectfn = ip_conntrack_q931_expect; 1607 exp->expectfn = ip_conntrack_q931_expect;
diff --git a/net/ipv4/netfilter/ip_conntrack_helper_pptp.c b/net/ipv4/netfilter/ip_conntrack_helper_pptp.c
index fb0aee691721..a2af5e0c7f99 100644
--- a/net/ipv4/netfilter/ip_conntrack_helper_pptp.c
+++ b/net/ipv4/netfilter/ip_conntrack_helper_pptp.c
@@ -242,10 +242,10 @@ exp_gre(struct ip_conntrack *ct,
242 exp_orig->tuple.dst.u.gre.key = callid; 242 exp_orig->tuple.dst.u.gre.key = callid;
243 exp_orig->tuple.dst.protonum = IPPROTO_GRE; 243 exp_orig->tuple.dst.protonum = IPPROTO_GRE;
244 244
245 exp_orig->mask.src.ip = 0xffffffff; 245 exp_orig->mask.src.ip = htonl(0xffffffff);
246 exp_orig->mask.src.u.all = 0; 246 exp_orig->mask.src.u.all = 0;
247 exp_orig->mask.dst.u.gre.key = htons(0xffff); 247 exp_orig->mask.dst.u.gre.key = htons(0xffff);
248 exp_orig->mask.dst.ip = 0xffffffff; 248 exp_orig->mask.dst.ip = htonl(0xffffffff);
249 exp_orig->mask.dst.protonum = 0xff; 249 exp_orig->mask.dst.protonum = 0xff;
250 250
251 exp_orig->master = ct; 251 exp_orig->master = ct;
diff --git a/net/ipv4/netfilter/ip_conntrack_irc.c b/net/ipv4/netfilter/ip_conntrack_irc.c
index 44889075f3b2..75f7c3db1619 100644
--- a/net/ipv4/netfilter/ip_conntrack_irc.c
+++ b/net/ipv4/netfilter/ip_conntrack_irc.c
@@ -218,7 +218,8 @@ static int help(struct sk_buff **pskb,
218 IPPROTO_TCP }}); 218 IPPROTO_TCP }});
219 exp->mask = ((struct ip_conntrack_tuple) 219 exp->mask = ((struct ip_conntrack_tuple)
220 { { 0, { 0 } }, 220 { { 0, { 0 } },
221 { 0xFFFFFFFF, { .tcp = { 0xFFFF } }, 0xFF }}); 221 { htonl(0xFFFFFFFF),
222 { .tcp = { htons(0xFFFF) } }, 0xFF }});
222 exp->expectfn = NULL; 223 exp->expectfn = NULL;
223 exp->flags = 0; 224 exp->flags = 0;
224 if (ip_nat_irc_hook) 225 if (ip_nat_irc_hook)
@@ -266,7 +267,7 @@ static int __init ip_conntrack_irc_init(void)
266 hlpr = &irc_helpers[i]; 267 hlpr = &irc_helpers[i];
267 hlpr->tuple.src.u.tcp.port = htons(ports[i]); 268 hlpr->tuple.src.u.tcp.port = htons(ports[i]);
268 hlpr->tuple.dst.protonum = IPPROTO_TCP; 269 hlpr->tuple.dst.protonum = IPPROTO_TCP;
269 hlpr->mask.src.u.tcp.port = 0xFFFF; 270 hlpr->mask.src.u.tcp.port = htons(0xFFFF);
270 hlpr->mask.dst.protonum = 0xFF; 271 hlpr->mask.dst.protonum = 0xFF;
271 hlpr->max_expected = max_dcc_channels; 272 hlpr->max_expected = max_dcc_channels;
272 hlpr->timeout = dcc_timeout; 273 hlpr->timeout = dcc_timeout;
diff --git a/net/ipv4/netfilter/ip_conntrack_netbios_ns.c b/net/ipv4/netfilter/ip_conntrack_netbios_ns.c
index 3d0b438783db..a1d6a89f64aa 100644
--- a/net/ipv4/netfilter/ip_conntrack_netbios_ns.c
+++ b/net/ipv4/netfilter/ip_conntrack_netbios_ns.c
@@ -48,7 +48,7 @@ static int help(struct sk_buff **pskb,
48 struct iphdr *iph = (*pskb)->nh.iph; 48 struct iphdr *iph = (*pskb)->nh.iph;
49 struct rtable *rt = (struct rtable *)(*pskb)->dst; 49 struct rtable *rt = (struct rtable *)(*pskb)->dst;
50 struct in_device *in_dev; 50 struct in_device *in_dev;
51 u_int32_t mask = 0; 51 __be32 mask = 0;
52 52
53 /* we're only interested in locally generated packets */ 53 /* we're only interested in locally generated packets */
54 if ((*pskb)->sk == NULL) 54 if ((*pskb)->sk == NULL)
@@ -78,12 +78,12 @@ static int help(struct sk_buff **pskb,
78 goto out; 78 goto out;
79 79
80 exp->tuple = ct->tuplehash[IP_CT_DIR_REPLY].tuple; 80 exp->tuple = ct->tuplehash[IP_CT_DIR_REPLY].tuple;
81 exp->tuple.src.u.udp.port = ntohs(NMBD_PORT); 81 exp->tuple.src.u.udp.port = htons(NMBD_PORT);
82 82
83 exp->mask.src.ip = mask; 83 exp->mask.src.ip = mask;
84 exp->mask.src.u.udp.port = 0xFFFF; 84 exp->mask.src.u.udp.port = htons(0xFFFF);
85 exp->mask.dst.ip = 0xFFFFFFFF; 85 exp->mask.dst.ip = htonl(0xFFFFFFFF);
86 exp->mask.dst.u.udp.port = 0xFFFF; 86 exp->mask.dst.u.udp.port = htons(0xFFFF);
87 exp->mask.dst.protonum = 0xFF; 87 exp->mask.dst.protonum = 0xFF;
88 88
89 exp->expectfn = NULL; 89 exp->expectfn = NULL;
@@ -115,7 +115,7 @@ static struct ip_conntrack_helper helper = {
115 .src = { 115 .src = {
116 .u = { 116 .u = {
117 .udp = { 117 .udp = {
118 .port = 0xFFFF, 118 .port = __constant_htons(0xFFFF),
119 } 119 }
120 } 120 }
121 }, 121 },
diff --git a/net/ipv4/netfilter/ip_conntrack_netlink.c b/net/ipv4/netfilter/ip_conntrack_netlink.c
index 52eddea27e93..53b6dffea6c2 100644
--- a/net/ipv4/netfilter/ip_conntrack_netlink.c
+++ b/net/ipv4/netfilter/ip_conntrack_netlink.c
@@ -78,8 +78,8 @@ ctnetlink_dump_tuples_ip(struct sk_buff *skb,
78{ 78{
79 struct nfattr *nest_parms = NFA_NEST(skb, CTA_TUPLE_IP); 79 struct nfattr *nest_parms = NFA_NEST(skb, CTA_TUPLE_IP);
80 80
81 NFA_PUT(skb, CTA_IP_V4_SRC, sizeof(u_int32_t), &tuple->src.ip); 81 NFA_PUT(skb, CTA_IP_V4_SRC, sizeof(__be32), &tuple->src.ip);
82 NFA_PUT(skb, CTA_IP_V4_DST, sizeof(u_int32_t), &tuple->dst.ip); 82 NFA_PUT(skb, CTA_IP_V4_DST, sizeof(__be32), &tuple->dst.ip);
83 83
84 NFA_NEST_END(skb, nest_parms); 84 NFA_NEST_END(skb, nest_parms);
85 85
@@ -110,7 +110,7 @@ ctnetlink_dump_tuples(struct sk_buff *skb,
110static inline int 110static inline int
111ctnetlink_dump_status(struct sk_buff *skb, const struct ip_conntrack *ct) 111ctnetlink_dump_status(struct sk_buff *skb, const struct ip_conntrack *ct)
112{ 112{
113 u_int32_t status = htonl((u_int32_t) ct->status); 113 __be32 status = htonl((u_int32_t) ct->status);
114 NFA_PUT(skb, CTA_STATUS, sizeof(status), &status); 114 NFA_PUT(skb, CTA_STATUS, sizeof(status), &status);
115 return 0; 115 return 0;
116 116
@@ -122,7 +122,7 @@ static inline int
122ctnetlink_dump_timeout(struct sk_buff *skb, const struct ip_conntrack *ct) 122ctnetlink_dump_timeout(struct sk_buff *skb, const struct ip_conntrack *ct)
123{ 123{
124 long timeout_l = ct->timeout.expires - jiffies; 124 long timeout_l = ct->timeout.expires - jiffies;
125 u_int32_t timeout; 125 __be32 timeout;
126 126
127 if (timeout_l < 0) 127 if (timeout_l < 0)
128 timeout = 0; 128 timeout = 0;
@@ -192,13 +192,13 @@ ctnetlink_dump_counters(struct sk_buff *skb, const struct ip_conntrack *ct,
192{ 192{
193 enum ctattr_type type = dir ? CTA_COUNTERS_REPLY: CTA_COUNTERS_ORIG; 193 enum ctattr_type type = dir ? CTA_COUNTERS_REPLY: CTA_COUNTERS_ORIG;
194 struct nfattr *nest_count = NFA_NEST(skb, type); 194 struct nfattr *nest_count = NFA_NEST(skb, type);
195 u_int32_t tmp; 195 __be32 tmp;
196 196
197 tmp = htonl(ct->counters[dir].packets); 197 tmp = htonl(ct->counters[dir].packets);
198 NFA_PUT(skb, CTA_COUNTERS32_PACKETS, sizeof(u_int32_t), &tmp); 198 NFA_PUT(skb, CTA_COUNTERS32_PACKETS, sizeof(__be32), &tmp);
199 199
200 tmp = htonl(ct->counters[dir].bytes); 200 tmp = htonl(ct->counters[dir].bytes);
201 NFA_PUT(skb, CTA_COUNTERS32_BYTES, sizeof(u_int32_t), &tmp); 201 NFA_PUT(skb, CTA_COUNTERS32_BYTES, sizeof(__be32), &tmp);
202 202
203 NFA_NEST_END(skb, nest_count); 203 NFA_NEST_END(skb, nest_count);
204 204
@@ -215,9 +215,9 @@ nfattr_failure:
215static inline int 215static inline int
216ctnetlink_dump_mark(struct sk_buff *skb, const struct ip_conntrack *ct) 216ctnetlink_dump_mark(struct sk_buff *skb, const struct ip_conntrack *ct)
217{ 217{
218 u_int32_t mark = htonl(ct->mark); 218 __be32 mark = htonl(ct->mark);
219 219
220 NFA_PUT(skb, CTA_MARK, sizeof(u_int32_t), &mark); 220 NFA_PUT(skb, CTA_MARK, sizeof(__be32), &mark);
221 return 0; 221 return 0;
222 222
223nfattr_failure: 223nfattr_failure:
@@ -230,8 +230,8 @@ nfattr_failure:
230static inline int 230static inline int
231ctnetlink_dump_id(struct sk_buff *skb, const struct ip_conntrack *ct) 231ctnetlink_dump_id(struct sk_buff *skb, const struct ip_conntrack *ct)
232{ 232{
233 u_int32_t id = htonl(ct->id); 233 __be32 id = htonl(ct->id);
234 NFA_PUT(skb, CTA_ID, sizeof(u_int32_t), &id); 234 NFA_PUT(skb, CTA_ID, sizeof(__be32), &id);
235 return 0; 235 return 0;
236 236
237nfattr_failure: 237nfattr_failure:
@@ -241,9 +241,9 @@ nfattr_failure:
241static inline int 241static inline int
242ctnetlink_dump_use(struct sk_buff *skb, const struct ip_conntrack *ct) 242ctnetlink_dump_use(struct sk_buff *skb, const struct ip_conntrack *ct)
243{ 243{
244 u_int32_t use = htonl(atomic_read(&ct->ct_general.use)); 244 __be32 use = htonl(atomic_read(&ct->ct_general.use));
245 245
246 NFA_PUT(skb, CTA_USE, sizeof(u_int32_t), &use); 246 NFA_PUT(skb, CTA_USE, sizeof(__be32), &use);
247 return 0; 247 return 0;
248 248
249nfattr_failure: 249nfattr_failure:
@@ -457,8 +457,8 @@ out:
457} 457}
458 458
459static const size_t cta_min_ip[CTA_IP_MAX] = { 459static const size_t cta_min_ip[CTA_IP_MAX] = {
460 [CTA_IP_V4_SRC-1] = sizeof(u_int32_t), 460 [CTA_IP_V4_SRC-1] = sizeof(__be32),
461 [CTA_IP_V4_DST-1] = sizeof(u_int32_t), 461 [CTA_IP_V4_DST-1] = sizeof(__be32),
462}; 462};
463 463
464static inline int 464static inline int
@@ -475,11 +475,11 @@ ctnetlink_parse_tuple_ip(struct nfattr *attr, struct ip_conntrack_tuple *tuple)
475 475
476 if (!tb[CTA_IP_V4_SRC-1]) 476 if (!tb[CTA_IP_V4_SRC-1])
477 return -EINVAL; 477 return -EINVAL;
478 tuple->src.ip = *(u_int32_t *)NFA_DATA(tb[CTA_IP_V4_SRC-1]); 478 tuple->src.ip = *(__be32 *)NFA_DATA(tb[CTA_IP_V4_SRC-1]);
479 479
480 if (!tb[CTA_IP_V4_DST-1]) 480 if (!tb[CTA_IP_V4_DST-1])
481 return -EINVAL; 481 return -EINVAL;
482 tuple->dst.ip = *(u_int32_t *)NFA_DATA(tb[CTA_IP_V4_DST-1]); 482 tuple->dst.ip = *(__be32 *)NFA_DATA(tb[CTA_IP_V4_DST-1]);
483 483
484 DEBUGP("leaving\n"); 484 DEBUGP("leaving\n");
485 485
@@ -602,8 +602,8 @@ static int ctnetlink_parse_nat_proto(struct nfattr *attr,
602} 602}
603 603
604static const size_t cta_min_nat[CTA_NAT_MAX] = { 604static const size_t cta_min_nat[CTA_NAT_MAX] = {
605 [CTA_NAT_MINIP-1] = sizeof(u_int32_t), 605 [CTA_NAT_MINIP-1] = sizeof(__be32),
606 [CTA_NAT_MAXIP-1] = sizeof(u_int32_t), 606 [CTA_NAT_MAXIP-1] = sizeof(__be32),
607}; 607};
608 608
609static inline int 609static inline int
@@ -623,12 +623,12 @@ ctnetlink_parse_nat(struct nfattr *nat,
623 return -EINVAL; 623 return -EINVAL;
624 624
625 if (tb[CTA_NAT_MINIP-1]) 625 if (tb[CTA_NAT_MINIP-1])
626 range->min_ip = *(u_int32_t *)NFA_DATA(tb[CTA_NAT_MINIP-1]); 626 range->min_ip = *(__be32 *)NFA_DATA(tb[CTA_NAT_MINIP-1]);
627 627
628 if (!tb[CTA_NAT_MAXIP-1]) 628 if (!tb[CTA_NAT_MAXIP-1])
629 range->max_ip = range->min_ip; 629 range->max_ip = range->min_ip;
630 else 630 else
631 range->max_ip = *(u_int32_t *)NFA_DATA(tb[CTA_NAT_MAXIP-1]); 631 range->max_ip = *(__be32 *)NFA_DATA(tb[CTA_NAT_MAXIP-1]);
632 632
633 if (range->min_ip) 633 if (range->min_ip)
634 range->flags |= IP_NAT_RANGE_MAP_IPS; 634 range->flags |= IP_NAT_RANGE_MAP_IPS;
@@ -663,11 +663,11 @@ ctnetlink_parse_help(struct nfattr *attr, char **helper_name)
663} 663}
664 664
665static const size_t cta_min[CTA_MAX] = { 665static const size_t cta_min[CTA_MAX] = {
666 [CTA_STATUS-1] = sizeof(u_int32_t), 666 [CTA_STATUS-1] = sizeof(__be32),
667 [CTA_TIMEOUT-1] = sizeof(u_int32_t), 667 [CTA_TIMEOUT-1] = sizeof(__be32),
668 [CTA_MARK-1] = sizeof(u_int32_t), 668 [CTA_MARK-1] = sizeof(__be32),
669 [CTA_USE-1] = sizeof(u_int32_t), 669 [CTA_USE-1] = sizeof(__be32),
670 [CTA_ID-1] = sizeof(u_int32_t) 670 [CTA_ID-1] = sizeof(__be32)
671}; 671};
672 672
673static int 673static int
@@ -706,7 +706,7 @@ ctnetlink_del_conntrack(struct sock *ctnl, struct sk_buff *skb,
706 ct = tuplehash_to_ctrack(h); 706 ct = tuplehash_to_ctrack(h);
707 707
708 if (cda[CTA_ID-1]) { 708 if (cda[CTA_ID-1]) {
709 u_int32_t id = ntohl(*(u_int32_t *)NFA_DATA(cda[CTA_ID-1])); 709 u_int32_t id = ntohl(*(__be32 *)NFA_DATA(cda[CTA_ID-1]));
710 if (ct->id != id) { 710 if (ct->id != id) {
711 ip_conntrack_put(ct); 711 ip_conntrack_put(ct);
712 return -ENOENT; 712 return -ENOENT;
@@ -808,7 +808,7 @@ static inline int
808ctnetlink_change_status(struct ip_conntrack *ct, struct nfattr *cda[]) 808ctnetlink_change_status(struct ip_conntrack *ct, struct nfattr *cda[])
809{ 809{
810 unsigned long d; 810 unsigned long d;
811 unsigned status = ntohl(*(u_int32_t *)NFA_DATA(cda[CTA_STATUS-1])); 811 unsigned status = ntohl(*(__be32 *)NFA_DATA(cda[CTA_STATUS-1]));
812 d = ct->status ^ status; 812 d = ct->status ^ status;
813 813
814 if (d & (IPS_EXPECTED|IPS_CONFIRMED|IPS_DYING)) 814 if (d & (IPS_EXPECTED|IPS_CONFIRMED|IPS_DYING))
@@ -903,7 +903,7 @@ ctnetlink_change_helper(struct ip_conntrack *ct, struct nfattr *cda[])
903static inline int 903static inline int
904ctnetlink_change_timeout(struct ip_conntrack *ct, struct nfattr *cda[]) 904ctnetlink_change_timeout(struct ip_conntrack *ct, struct nfattr *cda[])
905{ 905{
906 u_int32_t timeout = ntohl(*(u_int32_t *)NFA_DATA(cda[CTA_TIMEOUT-1])); 906 u_int32_t timeout = ntohl(*(__be32 *)NFA_DATA(cda[CTA_TIMEOUT-1]));
907 907
908 if (!del_timer(&ct->timeout)) 908 if (!del_timer(&ct->timeout))
909 return -ETIME; 909 return -ETIME;
@@ -966,7 +966,7 @@ ctnetlink_change_conntrack(struct ip_conntrack *ct, struct nfattr *cda[])
966 966
967#if defined(CONFIG_IP_NF_CONNTRACK_MARK) 967#if defined(CONFIG_IP_NF_CONNTRACK_MARK)
968 if (cda[CTA_MARK-1]) 968 if (cda[CTA_MARK-1])
969 ct->mark = ntohl(*(u_int32_t *)NFA_DATA(cda[CTA_MARK-1])); 969 ct->mark = ntohl(*(__be32 *)NFA_DATA(cda[CTA_MARK-1]));
970#endif 970#endif
971 971
972 DEBUGP("all done\n"); 972 DEBUGP("all done\n");
@@ -989,7 +989,7 @@ ctnetlink_create_conntrack(struct nfattr *cda[],
989 989
990 if (!cda[CTA_TIMEOUT-1]) 990 if (!cda[CTA_TIMEOUT-1])
991 goto err; 991 goto err;
992 ct->timeout.expires = ntohl(*(u_int32_t *)NFA_DATA(cda[CTA_TIMEOUT-1])); 992 ct->timeout.expires = ntohl(*(__be32 *)NFA_DATA(cda[CTA_TIMEOUT-1]));
993 993
994 ct->timeout.expires = jiffies + ct->timeout.expires * HZ; 994 ct->timeout.expires = jiffies + ct->timeout.expires * HZ;
995 ct->status |= IPS_CONFIRMED; 995 ct->status |= IPS_CONFIRMED;
@@ -1006,7 +1006,7 @@ ctnetlink_create_conntrack(struct nfattr *cda[],
1006 1006
1007#if defined(CONFIG_IP_NF_CONNTRACK_MARK) 1007#if defined(CONFIG_IP_NF_CONNTRACK_MARK)
1008 if (cda[CTA_MARK-1]) 1008 if (cda[CTA_MARK-1])
1009 ct->mark = ntohl(*(u_int32_t *)NFA_DATA(cda[CTA_MARK-1])); 1009 ct->mark = ntohl(*(__be32 *)NFA_DATA(cda[CTA_MARK-1]));
1010#endif 1010#endif
1011 1011
1012 ct->helper = ip_conntrack_helper_find_get(rtuple); 1012 ct->helper = ip_conntrack_helper_find_get(rtuple);
@@ -1138,8 +1138,8 @@ ctnetlink_exp_dump_expect(struct sk_buff *skb,
1138 const struct ip_conntrack_expect *exp) 1138 const struct ip_conntrack_expect *exp)
1139{ 1139{
1140 struct ip_conntrack *master = exp->master; 1140 struct ip_conntrack *master = exp->master;
1141 u_int32_t timeout = htonl((exp->timeout.expires - jiffies) / HZ); 1141 __be32 timeout = htonl((exp->timeout.expires - jiffies) / HZ);
1142 u_int32_t id = htonl(exp->id); 1142 __be32 id = htonl(exp->id);
1143 1143
1144 if (ctnetlink_exp_dump_tuple(skb, &exp->tuple, CTA_EXPECT_TUPLE) < 0) 1144 if (ctnetlink_exp_dump_tuple(skb, &exp->tuple, CTA_EXPECT_TUPLE) < 0)
1145 goto nfattr_failure; 1145 goto nfattr_failure;
@@ -1150,8 +1150,8 @@ ctnetlink_exp_dump_expect(struct sk_buff *skb,
1150 CTA_EXPECT_MASTER) < 0) 1150 CTA_EXPECT_MASTER) < 0)
1151 goto nfattr_failure; 1151 goto nfattr_failure;
1152 1152
1153 NFA_PUT(skb, CTA_EXPECT_TIMEOUT, sizeof(timeout), &timeout); 1153 NFA_PUT(skb, CTA_EXPECT_TIMEOUT, sizeof(__be32), &timeout);
1154 NFA_PUT(skb, CTA_EXPECT_ID, sizeof(u_int32_t), &id); 1154 NFA_PUT(skb, CTA_EXPECT_ID, sizeof(__be32), &id);
1155 1155
1156 return 0; 1156 return 0;
1157 1157
@@ -1272,8 +1272,8 @@ out:
1272} 1272}
1273 1273
1274static const size_t cta_min_exp[CTA_EXPECT_MAX] = { 1274static const size_t cta_min_exp[CTA_EXPECT_MAX] = {
1275 [CTA_EXPECT_TIMEOUT-1] = sizeof(u_int32_t), 1275 [CTA_EXPECT_TIMEOUT-1] = sizeof(__be32),
1276 [CTA_EXPECT_ID-1] = sizeof(u_int32_t) 1276 [CTA_EXPECT_ID-1] = sizeof(__be32)
1277}; 1277};
1278 1278
1279static int 1279static int
@@ -1321,7 +1321,7 @@ ctnetlink_get_expect(struct sock *ctnl, struct sk_buff *skb,
1321 return -ENOENT; 1321 return -ENOENT;
1322 1322
1323 if (cda[CTA_EXPECT_ID-1]) { 1323 if (cda[CTA_EXPECT_ID-1]) {
1324 u_int32_t id = *(u_int32_t *)NFA_DATA(cda[CTA_EXPECT_ID-1]); 1324 __be32 id = *(__be32 *)NFA_DATA(cda[CTA_EXPECT_ID-1]);
1325 if (exp->id != ntohl(id)) { 1325 if (exp->id != ntohl(id)) {
1326 ip_conntrack_expect_put(exp); 1326 ip_conntrack_expect_put(exp);
1327 return -ENOENT; 1327 return -ENOENT;
@@ -1375,8 +1375,8 @@ ctnetlink_del_expect(struct sock *ctnl, struct sk_buff *skb,
1375 return -ENOENT; 1375 return -ENOENT;
1376 1376
1377 if (cda[CTA_EXPECT_ID-1]) { 1377 if (cda[CTA_EXPECT_ID-1]) {
1378 u_int32_t id = 1378 __be32 id =
1379 *(u_int32_t *)NFA_DATA(cda[CTA_EXPECT_ID-1]); 1379 *(__be32 *)NFA_DATA(cda[CTA_EXPECT_ID-1]);
1380 if (exp->id != ntohl(id)) { 1380 if (exp->id != ntohl(id)) {
1381 ip_conntrack_expect_put(exp); 1381 ip_conntrack_expect_put(exp);
1382 return -ENOENT; 1382 return -ENOENT;
diff --git a/net/ipv4/netfilter/ip_conntrack_proto_icmp.c b/net/ipv4/netfilter/ip_conntrack_proto_icmp.c
index 09c40ebe3345..295b6fa340db 100644
--- a/net/ipv4/netfilter/ip_conntrack_proto_icmp.c
+++ b/net/ipv4/netfilter/ip_conntrack_proto_icmp.c
@@ -261,7 +261,7 @@ icmp_error(struct sk_buff *skb, enum ip_conntrack_info *ctinfo,
261static int icmp_tuple_to_nfattr(struct sk_buff *skb, 261static int icmp_tuple_to_nfattr(struct sk_buff *skb,
262 const struct ip_conntrack_tuple *t) 262 const struct ip_conntrack_tuple *t)
263{ 263{
264 NFA_PUT(skb, CTA_PROTO_ICMP_ID, sizeof(u_int16_t), 264 NFA_PUT(skb, CTA_PROTO_ICMP_ID, sizeof(__be16),
265 &t->src.u.icmp.id); 265 &t->src.u.icmp.id);
266 NFA_PUT(skb, CTA_PROTO_ICMP_TYPE, sizeof(u_int8_t), 266 NFA_PUT(skb, CTA_PROTO_ICMP_TYPE, sizeof(u_int8_t),
267 &t->dst.u.icmp.type); 267 &t->dst.u.icmp.type);
@@ -287,7 +287,7 @@ static int icmp_nfattr_to_tuple(struct nfattr *tb[],
287 tuple->dst.u.icmp.code = 287 tuple->dst.u.icmp.code =
288 *(u_int8_t *)NFA_DATA(tb[CTA_PROTO_ICMP_CODE-1]); 288 *(u_int8_t *)NFA_DATA(tb[CTA_PROTO_ICMP_CODE-1]);
289 tuple->src.u.icmp.id = 289 tuple->src.u.icmp.id =
290 *(u_int16_t *)NFA_DATA(tb[CTA_PROTO_ICMP_ID-1]); 290 *(__be16 *)NFA_DATA(tb[CTA_PROTO_ICMP_ID-1]);
291 291
292 if (tuple->dst.u.icmp.type >= sizeof(invmap) 292 if (tuple->dst.u.icmp.type >= sizeof(invmap)
293 || !invmap[tuple->dst.u.icmp.type]) 293 || !invmap[tuple->dst.u.icmp.type])
diff --git a/net/ipv4/netfilter/ip_conntrack_proto_sctp.c b/net/ipv4/netfilter/ip_conntrack_proto_sctp.c
index b908a4842e18..2443322e4128 100644
--- a/net/ipv4/netfilter/ip_conntrack_proto_sctp.c
+++ b/net/ipv4/netfilter/ip_conntrack_proto_sctp.c
@@ -210,7 +210,7 @@ static int sctp_print_conntrack(struct seq_file *s,
210for (offset = skb->nh.iph->ihl * 4 + sizeof(sctp_sctphdr_t), count = 0; \ 210for (offset = skb->nh.iph->ihl * 4 + sizeof(sctp_sctphdr_t), count = 0; \
211 offset < skb->len && \ 211 offset < skb->len && \
212 (sch = skb_header_pointer(skb, offset, sizeof(_sch), &_sch)); \ 212 (sch = skb_header_pointer(skb, offset, sizeof(_sch), &_sch)); \
213 offset += (htons(sch->length) + 3) & ~3, count++) 213 offset += (ntohs(sch->length) + 3) & ~3, count++)
214 214
215/* Some validity checks to make sure the chunks are fine */ 215/* Some validity checks to make sure the chunks are fine */
216static int do_basic_checks(struct ip_conntrack *conntrack, 216static int do_basic_checks(struct ip_conntrack *conntrack,
diff --git a/net/ipv4/netfilter/ip_conntrack_proto_tcp.c b/net/ipv4/netfilter/ip_conntrack_proto_tcp.c
index 03ae9a04cb37..06e4e8a6dd9f 100644
--- a/net/ipv4/netfilter/ip_conntrack_proto_tcp.c
+++ b/net/ipv4/netfilter/ip_conntrack_proto_tcp.c
@@ -519,8 +519,8 @@ static void tcp_sack(const struct sk_buff *skb,
519 519
520 /* Fast path for timestamp-only option */ 520 /* Fast path for timestamp-only option */
521 if (length == TCPOLEN_TSTAMP_ALIGNED*4 521 if (length == TCPOLEN_TSTAMP_ALIGNED*4
522 && *(__u32 *)ptr == 522 && *(__be32 *)ptr ==
523 __constant_ntohl((TCPOPT_NOP << 24) 523 __constant_htonl((TCPOPT_NOP << 24)
524 | (TCPOPT_NOP << 16) 524 | (TCPOPT_NOP << 16)
525 | (TCPOPT_TIMESTAMP << 8) 525 | (TCPOPT_TIMESTAMP << 8)
526 | TCPOLEN_TIMESTAMP)) 526 | TCPOLEN_TIMESTAMP))
@@ -551,7 +551,7 @@ static void tcp_sack(const struct sk_buff *skb,
551 for (i = 0; 551 for (i = 0;
552 i < (opsize - TCPOLEN_SACK_BASE); 552 i < (opsize - TCPOLEN_SACK_BASE);
553 i += TCPOLEN_SACK_PERBLOCK) { 553 i += TCPOLEN_SACK_PERBLOCK) {
554 tmp = ntohl(*((u_int32_t *)(ptr+i)+1)); 554 tmp = ntohl(*((__be32 *)(ptr+i)+1));
555 555
556 if (after(tmp, *sack)) 556 if (after(tmp, *sack))
557 *sack = tmp; 557 *sack = tmp;
diff --git a/net/ipv4/netfilter/ip_conntrack_sip.c b/net/ipv4/netfilter/ip_conntrack_sip.c
index 2893e9c74850..f4f75995a9e4 100644
--- a/net/ipv4/netfilter/ip_conntrack_sip.c
+++ b/net/ipv4/netfilter/ip_conntrack_sip.c
@@ -193,7 +193,7 @@ static int skp_digits_len(const char *dptr, const char *limit, int *shift)
193 193
194/* Simple ipaddr parser.. */ 194/* Simple ipaddr parser.. */
195static int parse_ipaddr(const char *cp, const char **endp, 195static int parse_ipaddr(const char *cp, const char **endp,
196 u_int32_t *ipaddr, const char *limit) 196 __be32 *ipaddr, const char *limit)
197{ 197{
198 unsigned long int val; 198 unsigned long int val;
199 int i, digit = 0; 199 int i, digit = 0;
@@ -227,7 +227,7 @@ static int parse_ipaddr(const char *cp, const char **endp,
227static int epaddr_len(const char *dptr, const char *limit, int *shift) 227static int epaddr_len(const char *dptr, const char *limit, int *shift)
228{ 228{
229 const char *aux = dptr; 229 const char *aux = dptr;
230 u_int32_t ip; 230 __be32 ip;
231 231
232 if (parse_ipaddr(dptr, &dptr, &ip, limit) < 0) { 232 if (parse_ipaddr(dptr, &dptr, &ip, limit) < 0) {
233 DEBUGP("ip: %s parse failed.!\n", dptr); 233 DEBUGP("ip: %s parse failed.!\n", dptr);
@@ -302,7 +302,7 @@ int ct_sip_get_info(const char *dptr, size_t dlen,
302static int set_expected_rtp(struct sk_buff **pskb, 302static int set_expected_rtp(struct sk_buff **pskb,
303 struct ip_conntrack *ct, 303 struct ip_conntrack *ct,
304 enum ip_conntrack_info ctinfo, 304 enum ip_conntrack_info ctinfo,
305 u_int32_t ipaddr, u_int16_t port, 305 __be32 ipaddr, u_int16_t port,
306 const char *dptr) 306 const char *dptr)
307{ 307{
308 struct ip_conntrack_expect *exp; 308 struct ip_conntrack_expect *exp;
@@ -319,10 +319,10 @@ static int set_expected_rtp(struct sk_buff **pskb,
319 exp->tuple.dst.u.udp.port = htons(port); 319 exp->tuple.dst.u.udp.port = htons(port);
320 exp->tuple.dst.protonum = IPPROTO_UDP; 320 exp->tuple.dst.protonum = IPPROTO_UDP;
321 321
322 exp->mask.src.ip = 0xFFFFFFFF; 322 exp->mask.src.ip = htonl(0xFFFFFFFF);
323 exp->mask.src.u.udp.port = 0; 323 exp->mask.src.u.udp.port = 0;
324 exp->mask.dst.ip = 0xFFFFFFFF; 324 exp->mask.dst.ip = htonl(0xFFFFFFFF);
325 exp->mask.dst.u.udp.port = 0xFFFF; 325 exp->mask.dst.u.udp.port = htons(0xFFFF);
326 exp->mask.dst.protonum = 0xFF; 326 exp->mask.dst.protonum = 0xFF;
327 327
328 exp->expectfn = NULL; 328 exp->expectfn = NULL;
@@ -349,7 +349,7 @@ static int sip_help(struct sk_buff **pskb,
349 const char *dptr; 349 const char *dptr;
350 int ret = NF_ACCEPT; 350 int ret = NF_ACCEPT;
351 int matchoff, matchlen; 351 int matchoff, matchlen;
352 u_int32_t ipaddr; 352 __be32 ipaddr;
353 u_int16_t port; 353 u_int16_t port;
354 354
355 /* No Data ? */ 355 /* No Data ? */
@@ -439,7 +439,7 @@ static int __init init(void)
439 439
440 sip[i].tuple.dst.protonum = IPPROTO_UDP; 440 sip[i].tuple.dst.protonum = IPPROTO_UDP;
441 sip[i].tuple.src.u.udp.port = htons(ports[i]); 441 sip[i].tuple.src.u.udp.port = htons(ports[i]);
442 sip[i].mask.src.u.udp.port = 0xFFFF; 442 sip[i].mask.src.u.udp.port = htons(0xFFFF);
443 sip[i].mask.dst.protonum = 0xFF; 443 sip[i].mask.dst.protonum = 0xFF;
444 sip[i].max_expected = 2; 444 sip[i].max_expected = 2;
445 sip[i].timeout = 3 * 60; /* 3 minutes */ 445 sip[i].timeout = 3 * 60; /* 3 minutes */
diff --git a/net/ipv4/netfilter/ip_conntrack_tftp.c b/net/ipv4/netfilter/ip_conntrack_tftp.c
index 7e33d3bed5e3..fe0b634dd377 100644
--- a/net/ipv4/netfilter/ip_conntrack_tftp.c
+++ b/net/ipv4/netfilter/ip_conntrack_tftp.c
@@ -70,10 +70,10 @@ static int tftp_help(struct sk_buff **pskb,
70 return NF_DROP; 70 return NF_DROP;
71 71
72 exp->tuple = ct->tuplehash[IP_CT_DIR_REPLY].tuple; 72 exp->tuple = ct->tuplehash[IP_CT_DIR_REPLY].tuple;
73 exp->mask.src.ip = 0xffffffff; 73 exp->mask.src.ip = htonl(0xffffffff);
74 exp->mask.src.u.udp.port = 0; 74 exp->mask.src.u.udp.port = 0;
75 exp->mask.dst.ip = 0xffffffff; 75 exp->mask.dst.ip = htonl(0xffffffff);
76 exp->mask.dst.u.udp.port = 0xffff; 76 exp->mask.dst.u.udp.port = htons(0xffff);
77 exp->mask.dst.protonum = 0xff; 77 exp->mask.dst.protonum = 0xff;
78 exp->expectfn = NULL; 78 exp->expectfn = NULL;
79 exp->flags = 0; 79 exp->flags = 0;
@@ -129,7 +129,7 @@ static int __init ip_conntrack_tftp_init(void)
129 tftp[i].tuple.dst.protonum = IPPROTO_UDP; 129 tftp[i].tuple.dst.protonum = IPPROTO_UDP;
130 tftp[i].tuple.src.u.udp.port = htons(ports[i]); 130 tftp[i].tuple.src.u.udp.port = htons(ports[i]);
131 tftp[i].mask.dst.protonum = 0xFF; 131 tftp[i].mask.dst.protonum = 0xFF;
132 tftp[i].mask.src.u.udp.port = 0xFFFF; 132 tftp[i].mask.src.u.udp.port = htons(0xFFFF);
133 tftp[i].max_expected = 1; 133 tftp[i].max_expected = 1;
134 tftp[i].timeout = 5 * 60; /* 5 minutes */ 134 tftp[i].timeout = 5 * 60; /* 5 minutes */
135 tftp[i].me = THIS_MODULE; 135 tftp[i].me = THIS_MODULE;
diff --git a/net/ipv4/netfilter/ip_nat_core.c b/net/ipv4/netfilter/ip_nat_core.c
index 71f3e09cbc84..4b6260a97408 100644
--- a/net/ipv4/netfilter/ip_nat_core.c
+++ b/net/ipv4/netfilter/ip_nat_core.c
@@ -82,7 +82,7 @@ static inline unsigned int
82hash_by_src(const struct ip_conntrack_tuple *tuple) 82hash_by_src(const struct ip_conntrack_tuple *tuple)
83{ 83{
84 /* Original src, to ensure we map it consistently if poss. */ 84 /* Original src, to ensure we map it consistently if poss. */
85 return jhash_3words(tuple->src.ip, tuple->src.u.all, 85 return jhash_3words((__force u32)tuple->src.ip, tuple->src.u.all,
86 tuple->dst.protonum, 0) % ip_nat_htable_size; 86 tuple->dst.protonum, 0) % ip_nat_htable_size;
87} 87}
88 88
@@ -190,7 +190,7 @@ find_best_ips_proto(struct ip_conntrack_tuple *tuple,
190 const struct ip_conntrack *conntrack, 190 const struct ip_conntrack *conntrack,
191 enum ip_nat_manip_type maniptype) 191 enum ip_nat_manip_type maniptype)
192{ 192{
193 u_int32_t *var_ipp; 193 __be32 *var_ipp;
194 /* Host order */ 194 /* Host order */
195 u_int32_t minip, maxip, j; 195 u_int32_t minip, maxip, j;
196 196
@@ -217,7 +217,7 @@ find_best_ips_proto(struct ip_conntrack_tuple *tuple,
217 * like this), even across reboots. */ 217 * like this), even across reboots. */
218 minip = ntohl(range->min_ip); 218 minip = ntohl(range->min_ip);
219 maxip = ntohl(range->max_ip); 219 maxip = ntohl(range->max_ip);
220 j = jhash_2words(tuple->src.ip, tuple->dst.ip, 0); 220 j = jhash_2words((__force u32)tuple->src.ip, (__force u32)tuple->dst.ip, 0);
221 *var_ipp = htonl(minip + j % (maxip - minip + 1)); 221 *var_ipp = htonl(minip + j % (maxip - minip + 1));
222} 222}
223 223
@@ -534,9 +534,9 @@ int
534ip_nat_port_range_to_nfattr(struct sk_buff *skb, 534ip_nat_port_range_to_nfattr(struct sk_buff *skb,
535 const struct ip_nat_range *range) 535 const struct ip_nat_range *range)
536{ 536{
537 NFA_PUT(skb, CTA_PROTONAT_PORT_MIN, sizeof(u_int16_t), 537 NFA_PUT(skb, CTA_PROTONAT_PORT_MIN, sizeof(__be16),
538 &range->min.tcp.port); 538 &range->min.tcp.port);
539 NFA_PUT(skb, CTA_PROTONAT_PORT_MAX, sizeof(u_int16_t), 539 NFA_PUT(skb, CTA_PROTONAT_PORT_MAX, sizeof(__be16),
540 &range->max.tcp.port); 540 &range->max.tcp.port);
541 541
542 return 0; 542 return 0;
@@ -555,7 +555,7 @@ ip_nat_port_nfattr_to_range(struct nfattr *tb[], struct ip_nat_range *range)
555 if (tb[CTA_PROTONAT_PORT_MIN-1]) { 555 if (tb[CTA_PROTONAT_PORT_MIN-1]) {
556 ret = 1; 556 ret = 1;
557 range->min.tcp.port = 557 range->min.tcp.port =
558 *(u_int16_t *)NFA_DATA(tb[CTA_PROTONAT_PORT_MIN-1]); 558 *(__be16 *)NFA_DATA(tb[CTA_PROTONAT_PORT_MIN-1]);
559 } 559 }
560 560
561 if (!tb[CTA_PROTONAT_PORT_MAX-1]) { 561 if (!tb[CTA_PROTONAT_PORT_MAX-1]) {
@@ -564,7 +564,7 @@ ip_nat_port_nfattr_to_range(struct nfattr *tb[], struct ip_nat_range *range)
564 } else { 564 } else {
565 ret = 1; 565 ret = 1;
566 range->max.tcp.port = 566 range->max.tcp.port =
567 *(u_int16_t *)NFA_DATA(tb[CTA_PROTONAT_PORT_MAX-1]); 567 *(__be16 *)NFA_DATA(tb[CTA_PROTONAT_PORT_MAX-1]);
568 } 568 }
569 569
570 return ret; 570 return ret;
diff --git a/net/ipv4/netfilter/ip_nat_ftp.c b/net/ipv4/netfilter/ip_nat_ftp.c
index 3328fc5c5f50..a71c233d8112 100644
--- a/net/ipv4/netfilter/ip_nat_ftp.c
+++ b/net/ipv4/netfilter/ip_nat_ftp.c
@@ -34,7 +34,7 @@ MODULE_DESCRIPTION("ftp NAT helper");
34 34
35static int 35static int
36mangle_rfc959_packet(struct sk_buff **pskb, 36mangle_rfc959_packet(struct sk_buff **pskb,
37 u_int32_t newip, 37 __be32 newip,
38 u_int16_t port, 38 u_int16_t port,
39 unsigned int matchoff, 39 unsigned int matchoff,
40 unsigned int matchlen, 40 unsigned int matchlen,
@@ -57,7 +57,7 @@ mangle_rfc959_packet(struct sk_buff **pskb,
57/* |1|132.235.1.2|6275| */ 57/* |1|132.235.1.2|6275| */
58static int 58static int
59mangle_eprt_packet(struct sk_buff **pskb, 59mangle_eprt_packet(struct sk_buff **pskb,
60 u_int32_t newip, 60 __be32 newip,
61 u_int16_t port, 61 u_int16_t port,
62 unsigned int matchoff, 62 unsigned int matchoff,
63 unsigned int matchlen, 63 unsigned int matchlen,
@@ -79,7 +79,7 @@ mangle_eprt_packet(struct sk_buff **pskb,
79/* |1|132.235.1.2|6275| */ 79/* |1|132.235.1.2|6275| */
80static int 80static int
81mangle_epsv_packet(struct sk_buff **pskb, 81mangle_epsv_packet(struct sk_buff **pskb,
82 u_int32_t newip, 82 __be32 newip,
83 u_int16_t port, 83 u_int16_t port,
84 unsigned int matchoff, 84 unsigned int matchoff,
85 unsigned int matchlen, 85 unsigned int matchlen,
@@ -98,7 +98,7 @@ mangle_epsv_packet(struct sk_buff **pskb,
98 matchlen, buffer, strlen(buffer)); 98 matchlen, buffer, strlen(buffer));
99} 99}
100 100
101static int (*mangle[])(struct sk_buff **, u_int32_t, u_int16_t, 101static int (*mangle[])(struct sk_buff **, __be32, u_int16_t,
102 unsigned int, 102 unsigned int,
103 unsigned int, 103 unsigned int,
104 struct ip_conntrack *, 104 struct ip_conntrack *,
@@ -120,7 +120,7 @@ static unsigned int ip_nat_ftp(struct sk_buff **pskb,
120 struct ip_conntrack_expect *exp, 120 struct ip_conntrack_expect *exp,
121 u32 *seq) 121 u32 *seq)
122{ 122{
123 u_int32_t newip; 123 __be32 newip;
124 u_int16_t port; 124 u_int16_t port;
125 int dir = CTINFO2DIR(ctinfo); 125 int dir = CTINFO2DIR(ctinfo);
126 struct ip_conntrack *ct = exp->master; 126 struct ip_conntrack *ct = exp->master;
diff --git a/net/ipv4/netfilter/ip_nat_helper.c b/net/ipv4/netfilter/ip_nat_helper.c
index 7f6a75984f6c..3bf858480558 100644
--- a/net/ipv4/netfilter/ip_nat_helper.c
+++ b/net/ipv4/netfilter/ip_nat_helper.c
@@ -189,7 +189,7 @@ ip_nat_mangle_tcp_packet(struct sk_buff **pskb,
189 datalen, 0)); 189 datalen, 0));
190 } else 190 } else
191 tcph->check = nf_proto_csum_update(*pskb, 191 tcph->check = nf_proto_csum_update(*pskb,
192 htons(oldlen) ^ 0xFFFF, 192 htons(oldlen) ^ htons(0xFFFF),
193 htons(datalen), 193 htons(datalen),
194 tcph->check, 1); 194 tcph->check, 1);
195 195
@@ -267,7 +267,7 @@ ip_nat_mangle_udp_packet(struct sk_buff **pskb,
267 udph->check = -1; 267 udph->check = -1;
268 } else 268 } else
269 udph->check = nf_proto_csum_update(*pskb, 269 udph->check = nf_proto_csum_update(*pskb,
270 htons(oldlen) ^ 0xFFFF, 270 htons(oldlen) ^ htons(0xFFFF),
271 htons(datalen), 271 htons(datalen),
272 udph->check, 1); 272 udph->check, 1);
273 return 1; 273 return 1;
@@ -283,27 +283,25 @@ sack_adjust(struct sk_buff *skb,
283 struct ip_nat_seq *natseq) 283 struct ip_nat_seq *natseq)
284{ 284{
285 while (sackoff < sackend) { 285 while (sackoff < sackend) {
286 struct tcp_sack_block *sack; 286 struct tcp_sack_block_wire *sack;
287 u_int32_t new_start_seq, new_end_seq; 287 __be32 new_start_seq, new_end_seq;
288 288
289 sack = (void *)skb->data + sackoff; 289 sack = (void *)skb->data + sackoff;
290 if (after(ntohl(sack->start_seq) - natseq->offset_before, 290 if (after(ntohl(sack->start_seq) - natseq->offset_before,
291 natseq->correction_pos)) 291 natseq->correction_pos))
292 new_start_seq = ntohl(sack->start_seq) 292 new_start_seq = htonl(ntohl(sack->start_seq)
293 - natseq->offset_after; 293 - natseq->offset_after);
294 else 294 else
295 new_start_seq = ntohl(sack->start_seq) 295 new_start_seq = htonl(ntohl(sack->start_seq)
296 - natseq->offset_before; 296 - natseq->offset_before);
297 new_start_seq = htonl(new_start_seq);
298 297
299 if (after(ntohl(sack->end_seq) - natseq->offset_before, 298 if (after(ntohl(sack->end_seq) - natseq->offset_before,
300 natseq->correction_pos)) 299 natseq->correction_pos))
301 new_end_seq = ntohl(sack->end_seq) 300 new_end_seq = htonl(ntohl(sack->end_seq)
302 - natseq->offset_after; 301 - natseq->offset_after);
303 else 302 else
304 new_end_seq = ntohl(sack->end_seq) 303 new_end_seq = htonl(ntohl(sack->end_seq)
305 - natseq->offset_before; 304 - natseq->offset_before);
306 new_end_seq = htonl(new_end_seq);
307 305
308 DEBUGP("sack_adjust: start_seq: %d->%d, end_seq: %d->%d\n", 306 DEBUGP("sack_adjust: start_seq: %d->%d, end_seq: %d->%d\n",
309 ntohl(sack->start_seq), new_start_seq, 307 ntohl(sack->start_seq), new_start_seq,
@@ -375,7 +373,8 @@ ip_nat_seq_adjust(struct sk_buff **pskb,
375 enum ip_conntrack_info ctinfo) 373 enum ip_conntrack_info ctinfo)
376{ 374{
377 struct tcphdr *tcph; 375 struct tcphdr *tcph;
378 int dir, newseq, newack; 376 int dir;
377 __be32 newseq, newack;
379 struct ip_nat_seq *this_way, *other_way; 378 struct ip_nat_seq *this_way, *other_way;
380 379
381 dir = CTINFO2DIR(ctinfo); 380 dir = CTINFO2DIR(ctinfo);
@@ -388,17 +387,15 @@ ip_nat_seq_adjust(struct sk_buff **pskb,
388 387
389 tcph = (void *)(*pskb)->data + (*pskb)->nh.iph->ihl*4; 388 tcph = (void *)(*pskb)->data + (*pskb)->nh.iph->ihl*4;
390 if (after(ntohl(tcph->seq), this_way->correction_pos)) 389 if (after(ntohl(tcph->seq), this_way->correction_pos))
391 newseq = ntohl(tcph->seq) + this_way->offset_after; 390 newseq = htonl(ntohl(tcph->seq) + this_way->offset_after);
392 else 391 else
393 newseq = ntohl(tcph->seq) + this_way->offset_before; 392 newseq = htonl(ntohl(tcph->seq) + this_way->offset_before);
394 newseq = htonl(newseq);
395 393
396 if (after(ntohl(tcph->ack_seq) - other_way->offset_before, 394 if (after(ntohl(tcph->ack_seq) - other_way->offset_before,
397 other_way->correction_pos)) 395 other_way->correction_pos))
398 newack = ntohl(tcph->ack_seq) - other_way->offset_after; 396 newack = htonl(ntohl(tcph->ack_seq) - other_way->offset_after);
399 else 397 else
400 newack = ntohl(tcph->ack_seq) - other_way->offset_before; 398 newack = htonl(ntohl(tcph->ack_seq) - other_way->offset_before);
401 newack = htonl(newack);
402 399
403 tcph->check = nf_proto_csum_update(*pskb, ~tcph->seq, newseq, 400 tcph->check = nf_proto_csum_update(*pskb, ~tcph->seq, newseq,
404 tcph->check, 0); 401 tcph->check, 0);
diff --git a/net/ipv4/netfilter/ip_nat_helper_h323.c b/net/ipv4/netfilter/ip_nat_helper_h323.c
index 419b878fb467..4a7d34466ee2 100644
--- a/net/ipv4/netfilter/ip_nat_helper_h323.c
+++ b/net/ipv4/netfilter/ip_nat_helper_h323.c
@@ -32,13 +32,13 @@
32/****************************************************************************/ 32/****************************************************************************/
33static int set_addr(struct sk_buff **pskb, 33static int set_addr(struct sk_buff **pskb,
34 unsigned char **data, int dataoff, 34 unsigned char **data, int dataoff,
35 unsigned int addroff, u_int32_t ip, u_int16_t port) 35 unsigned int addroff, __be32 ip, u_int16_t port)
36{ 36{
37 enum ip_conntrack_info ctinfo; 37 enum ip_conntrack_info ctinfo;
38 struct ip_conntrack *ct = ip_conntrack_get(*pskb, &ctinfo); 38 struct ip_conntrack *ct = ip_conntrack_get(*pskb, &ctinfo);
39 struct { 39 struct {
40 u_int32_t ip; 40 __be32 ip;
41 u_int16_t port; 41 __be16 port;
42 } __attribute__ ((__packed__)) buf; 42 } __attribute__ ((__packed__)) buf;
43 struct tcphdr _tcph, *th; 43 struct tcphdr _tcph, *th;
44 44
@@ -86,7 +86,7 @@ static int set_addr(struct sk_buff **pskb,
86static int set_h225_addr(struct sk_buff **pskb, 86static int set_h225_addr(struct sk_buff **pskb,
87 unsigned char **data, int dataoff, 87 unsigned char **data, int dataoff,
88 TransportAddress * addr, 88 TransportAddress * addr,
89 u_int32_t ip, u_int16_t port) 89 __be32 ip, u_int16_t port)
90{ 90{
91 return set_addr(pskb, data, dataoff, addr->ipAddress.ip, ip, port); 91 return set_addr(pskb, data, dataoff, addr->ipAddress.ip, ip, port);
92} 92}
@@ -95,7 +95,7 @@ static int set_h225_addr(struct sk_buff **pskb,
95static int set_h245_addr(struct sk_buff **pskb, 95static int set_h245_addr(struct sk_buff **pskb,
96 unsigned char **data, int dataoff, 96 unsigned char **data, int dataoff,
97 H245_TransportAddress * addr, 97 H245_TransportAddress * addr,
98 u_int32_t ip, u_int16_t port) 98 __be32 ip, u_int16_t port)
99{ 99{
100 return set_addr(pskb, data, dataoff, 100 return set_addr(pskb, data, dataoff,
101 addr->unicastAddress.iPAddress.network, ip, port); 101 addr->unicastAddress.iPAddress.network, ip, port);
@@ -110,7 +110,7 @@ static int set_sig_addr(struct sk_buff **pskb, struct ip_conntrack *ct,
110 struct ip_ct_h323_master *info = &ct->help.ct_h323_info; 110 struct ip_ct_h323_master *info = &ct->help.ct_h323_info;
111 int dir = CTINFO2DIR(ctinfo); 111 int dir = CTINFO2DIR(ctinfo);
112 int i; 112 int i;
113 u_int32_t ip; 113 __be32 ip;
114 u_int16_t port; 114 u_int16_t port;
115 115
116 for (i = 0; i < count; i++) { 116 for (i = 0; i < count; i++) {
@@ -164,7 +164,7 @@ static int set_ras_addr(struct sk_buff **pskb, struct ip_conntrack *ct,
164{ 164{
165 int dir = CTINFO2DIR(ctinfo); 165 int dir = CTINFO2DIR(ctinfo);
166 int i; 166 int i;
167 u_int32_t ip; 167 __be32 ip;
168 u_int16_t port; 168 u_int16_t port;
169 169
170 for (i = 0; i < count; i++) { 170 for (i = 0; i < count; i++) {
@@ -433,7 +433,7 @@ static int nat_q931(struct sk_buff **pskb, struct ip_conntrack *ct,
433 struct ip_ct_h323_master *info = &ct->help.ct_h323_info; 433 struct ip_ct_h323_master *info = &ct->help.ct_h323_info;
434 int dir = CTINFO2DIR(ctinfo); 434 int dir = CTINFO2DIR(ctinfo);
435 u_int16_t nated_port = port; 435 u_int16_t nated_port = port;
436 u_int32_t ip; 436 __be32 ip;
437 437
438 /* Set expectations for NAT */ 438 /* Set expectations for NAT */
439 exp->saved_proto.tcp.port = exp->tuple.dst.u.tcp.port; 439 exp->saved_proto.tcp.port = exp->tuple.dst.u.tcp.port;
diff --git a/net/ipv4/netfilter/ip_nat_helper_pptp.c b/net/ipv4/netfilter/ip_nat_helper_pptp.c
index 2ff578807123..329fdcd7d702 100644
--- a/net/ipv4/netfilter/ip_nat_helper_pptp.c
+++ b/net/ipv4/netfilter/ip_nat_helper_pptp.c
@@ -51,7 +51,7 @@
51 51
52#define IP_NAT_PPTP_VERSION "3.0" 52#define IP_NAT_PPTP_VERSION "3.0"
53 53
54#define REQ_CID(req, off) (*(u_int16_t *)((char *)(req) + (off))) 54#define REQ_CID(req, off) (*(__be16 *)((char *)(req) + (off)))
55 55
56MODULE_LICENSE("GPL"); 56MODULE_LICENSE("GPL");
57MODULE_AUTHOR("Harald Welte <laforge@gnumonks.org>"); 57MODULE_AUTHOR("Harald Welte <laforge@gnumonks.org>");
diff --git a/net/ipv4/netfilter/ip_nat_proto_icmp.c b/net/ipv4/netfilter/ip_nat_proto_icmp.c
index ec50cc295317..3f6efc13ac74 100644
--- a/net/ipv4/netfilter/ip_nat_proto_icmp.c
+++ b/net/ipv4/netfilter/ip_nat_proto_icmp.c
@@ -67,7 +67,7 @@ icmp_manip_pkt(struct sk_buff **pskb,
67 67
68 hdr = (struct icmphdr *)((*pskb)->data + hdroff); 68 hdr = (struct icmphdr *)((*pskb)->data + hdroff);
69 hdr->checksum = nf_proto_csum_update(*pskb, 69 hdr->checksum = nf_proto_csum_update(*pskb,
70 hdr->un.echo.id ^ 0xFFFF, 70 hdr->un.echo.id ^ htons(0xFFFF),
71 tuple->src.u.icmp.id, 71 tuple->src.u.icmp.id,
72 hdr->checksum, 0); 72 hdr->checksum, 0);
73 hdr->un.echo.id = tuple->src.u.icmp.id; 73 hdr->un.echo.id = tuple->src.u.icmp.id;
diff --git a/net/ipv4/netfilter/ip_nat_proto_tcp.c b/net/ipv4/netfilter/ip_nat_proto_tcp.c
index 72a6307bd2db..12deb13b93b1 100644
--- a/net/ipv4/netfilter/ip_nat_proto_tcp.c
+++ b/net/ipv4/netfilter/ip_nat_proto_tcp.c
@@ -24,7 +24,7 @@ tcp_in_range(const struct ip_conntrack_tuple *tuple,
24 const union ip_conntrack_manip_proto *min, 24 const union ip_conntrack_manip_proto *min,
25 const union ip_conntrack_manip_proto *max) 25 const union ip_conntrack_manip_proto *max)
26{ 26{
27 u_int16_t port; 27 __be16 port;
28 28
29 if (maniptype == IP_NAT_MANIP_SRC) 29 if (maniptype == IP_NAT_MANIP_SRC)
30 port = tuple->src.u.tcp.port; 30 port = tuple->src.u.tcp.port;
@@ -42,7 +42,7 @@ tcp_unique_tuple(struct ip_conntrack_tuple *tuple,
42 const struct ip_conntrack *conntrack) 42 const struct ip_conntrack *conntrack)
43{ 43{
44 static u_int16_t port; 44 static u_int16_t port;
45 u_int16_t *portptr; 45 __be16 *portptr;
46 unsigned int range_size, min, i; 46 unsigned int range_size, min, i;
47 47
48 if (maniptype == IP_NAT_MANIP_SRC) 48 if (maniptype == IP_NAT_MANIP_SRC)
@@ -93,8 +93,8 @@ tcp_manip_pkt(struct sk_buff **pskb,
93 struct iphdr *iph = (struct iphdr *)((*pskb)->data + iphdroff); 93 struct iphdr *iph = (struct iphdr *)((*pskb)->data + iphdroff);
94 struct tcphdr *hdr; 94 struct tcphdr *hdr;
95 unsigned int hdroff = iphdroff + iph->ihl*4; 95 unsigned int hdroff = iphdroff + iph->ihl*4;
96 u32 oldip, newip; 96 __be32 oldip, newip;
97 u16 *portptr, newport, oldport; 97 __be16 *portptr, newport, oldport;
98 int hdrsize = 8; /* TCP connection tracking guarantees this much */ 98 int hdrsize = 8; /* TCP connection tracking guarantees this much */
99 99
100 /* this could be a inner header returned in icmp packet; in such 100 /* this could be a inner header returned in icmp packet; in such
@@ -130,7 +130,7 @@ tcp_manip_pkt(struct sk_buff **pskb,
130 return 1; 130 return 1;
131 131
132 hdr->check = nf_proto_csum_update(*pskb, ~oldip, newip, hdr->check, 1); 132 hdr->check = nf_proto_csum_update(*pskb, ~oldip, newip, hdr->check, 1);
133 hdr->check = nf_proto_csum_update(*pskb, oldport ^ 0xFFFF, newport, 133 hdr->check = nf_proto_csum_update(*pskb, oldport ^ htons(0xFFFF), newport,
134 hdr->check, 0); 134 hdr->check, 0);
135 return 1; 135 return 1;
136} 136}
diff --git a/net/ipv4/netfilter/ip_nat_proto_udp.c b/net/ipv4/netfilter/ip_nat_proto_udp.c
index 5da196ae758c..4bbec7730d18 100644
--- a/net/ipv4/netfilter/ip_nat_proto_udp.c
+++ b/net/ipv4/netfilter/ip_nat_proto_udp.c
@@ -24,7 +24,7 @@ udp_in_range(const struct ip_conntrack_tuple *tuple,
24 const union ip_conntrack_manip_proto *min, 24 const union ip_conntrack_manip_proto *min,
25 const union ip_conntrack_manip_proto *max) 25 const union ip_conntrack_manip_proto *max)
26{ 26{
27 u_int16_t port; 27 __be16 port;
28 28
29 if (maniptype == IP_NAT_MANIP_SRC) 29 if (maniptype == IP_NAT_MANIP_SRC)
30 port = tuple->src.u.udp.port; 30 port = tuple->src.u.udp.port;
@@ -42,7 +42,7 @@ udp_unique_tuple(struct ip_conntrack_tuple *tuple,
42 const struct ip_conntrack *conntrack) 42 const struct ip_conntrack *conntrack)
43{ 43{
44 static u_int16_t port; 44 static u_int16_t port;
45 u_int16_t *portptr; 45 __be16 *portptr;
46 unsigned int range_size, min, i; 46 unsigned int range_size, min, i;
47 47
48 if (maniptype == IP_NAT_MANIP_SRC) 48 if (maniptype == IP_NAT_MANIP_SRC)
@@ -91,8 +91,8 @@ udp_manip_pkt(struct sk_buff **pskb,
91 struct iphdr *iph = (struct iphdr *)((*pskb)->data + iphdroff); 91 struct iphdr *iph = (struct iphdr *)((*pskb)->data + iphdroff);
92 struct udphdr *hdr; 92 struct udphdr *hdr;
93 unsigned int hdroff = iphdroff + iph->ihl*4; 93 unsigned int hdroff = iphdroff + iph->ihl*4;
94 u32 oldip, newip; 94 __be32 oldip, newip;
95 u16 *portptr, newport; 95 __be16 *portptr, newport;
96 96
97 if (!skb_make_writable(pskb, hdroff + sizeof(*hdr))) 97 if (!skb_make_writable(pskb, hdroff + sizeof(*hdr)))
98 return 0; 98 return 0;
@@ -118,7 +118,7 @@ udp_manip_pkt(struct sk_buff **pskb,
118 hdr->check = nf_proto_csum_update(*pskb, ~oldip, newip, 118 hdr->check = nf_proto_csum_update(*pskb, ~oldip, newip,
119 hdr->check, 1); 119 hdr->check, 1);
120 hdr->check = nf_proto_csum_update(*pskb, 120 hdr->check = nf_proto_csum_update(*pskb,
121 *portptr ^ 0xFFFF, newport, 121 *portptr ^ htons(0xFFFF), newport,
122 hdr->check, 0); 122 hdr->check, 0);
123 if (!hdr->check) 123 if (!hdr->check)
124 hdr->check = -1; 124 hdr->check = -1;
diff --git a/net/ipv4/netfilter/ip_nat_rule.c b/net/ipv4/netfilter/ip_nat_rule.c
index 7b703839aa58..a176aa3031e0 100644
--- a/net/ipv4/netfilter/ip_nat_rule.c
+++ b/net/ipv4/netfilter/ip_nat_rule.c
@@ -119,7 +119,7 @@ static unsigned int ipt_snat_target(struct sk_buff **pskb,
119} 119}
120 120
121/* Before 2.6.11 we did implicit source NAT if required. Warn about change. */ 121/* Before 2.6.11 we did implicit source NAT if required. Warn about change. */
122static void warn_if_extra_mangle(u32 dstip, u32 srcip) 122static void warn_if_extra_mangle(__be32 dstip, __be32 srcip)
123{ 123{
124 static int warned = 0; 124 static int warned = 0;
125 struct flowi fl = { .nl_u = { .ip4_u = { .daddr = dstip } } }; 125 struct flowi fl = { .nl_u = { .ip4_u = { .daddr = dstip } } };
@@ -205,7 +205,7 @@ alloc_null_binding(struct ip_conntrack *conntrack,
205 per-proto parts (hence not IP_NAT_RANGE_PROTO_SPECIFIED). 205 per-proto parts (hence not IP_NAT_RANGE_PROTO_SPECIFIED).
206 Use reply in case it's already been mangled (eg local packet). 206 Use reply in case it's already been mangled (eg local packet).
207 */ 207 */
208 u_int32_t ip 208 __be32 ip
209 = (HOOK2MANIP(hooknum) == IP_NAT_MANIP_SRC 209 = (HOOK2MANIP(hooknum) == IP_NAT_MANIP_SRC
210 ? conntrack->tuplehash[IP_CT_DIR_REPLY].tuple.dst.ip 210 ? conntrack->tuplehash[IP_CT_DIR_REPLY].tuple.dst.ip
211 : conntrack->tuplehash[IP_CT_DIR_REPLY].tuple.src.ip); 211 : conntrack->tuplehash[IP_CT_DIR_REPLY].tuple.src.ip);
@@ -222,7 +222,7 @@ alloc_null_binding_confirmed(struct ip_conntrack *conntrack,
222 struct ip_nat_info *info, 222 struct ip_nat_info *info,
223 unsigned int hooknum) 223 unsigned int hooknum)
224{ 224{
225 u_int32_t ip 225 __be32 ip
226 = (HOOK2MANIP(hooknum) == IP_NAT_MANIP_SRC 226 = (HOOK2MANIP(hooknum) == IP_NAT_MANIP_SRC
227 ? conntrack->tuplehash[IP_CT_DIR_REPLY].tuple.dst.ip 227 ? conntrack->tuplehash[IP_CT_DIR_REPLY].tuple.dst.ip
228 : conntrack->tuplehash[IP_CT_DIR_REPLY].tuple.src.ip); 228 : conntrack->tuplehash[IP_CT_DIR_REPLY].tuple.src.ip);
diff --git a/net/ipv4/netfilter/ip_nat_sip.c b/net/ipv4/netfilter/ip_nat_sip.c
index 6ffba63adca2..71fc2730a007 100644
--- a/net/ipv4/netfilter/ip_nat_sip.c
+++ b/net/ipv4/netfilter/ip_nat_sip.c
@@ -60,8 +60,8 @@ static unsigned int ip_nat_sip(struct sk_buff **pskb,
60 enum ip_conntrack_dir dir = CTINFO2DIR(ctinfo); 60 enum ip_conntrack_dir dir = CTINFO2DIR(ctinfo);
61 char buffer[sizeof("nnn.nnn.nnn.nnn:nnnnn")]; 61 char buffer[sizeof("nnn.nnn.nnn.nnn:nnnnn")];
62 unsigned int bufflen, dataoff; 62 unsigned int bufflen, dataoff;
63 u_int32_t ip; 63 __be32 ip;
64 u_int16_t port; 64 __be16 port;
65 65
66 dataoff = (*pskb)->nh.iph->ihl*4 + sizeof(struct udphdr); 66 dataoff = (*pskb)->nh.iph->ihl*4 + sizeof(struct udphdr);
67 67
@@ -159,7 +159,7 @@ static int mangle_content_len(struct sk_buff **pskb,
159static unsigned int mangle_sdp(struct sk_buff **pskb, 159static unsigned int mangle_sdp(struct sk_buff **pskb,
160 enum ip_conntrack_info ctinfo, 160 enum ip_conntrack_info ctinfo,
161 struct ip_conntrack *ct, 161 struct ip_conntrack *ct,
162 u_int32_t newip, u_int16_t port, 162 __be32 newip, u_int16_t port,
163 const char *dptr) 163 const char *dptr)
164{ 164{
165 char buffer[sizeof("nnn.nnn.nnn.nnn")]; 165 char buffer[sizeof("nnn.nnn.nnn.nnn")];
@@ -195,7 +195,7 @@ static unsigned int ip_nat_sdp(struct sk_buff **pskb,
195{ 195{
196 struct ip_conntrack *ct = exp->master; 196 struct ip_conntrack *ct = exp->master;
197 enum ip_conntrack_dir dir = CTINFO2DIR(ctinfo); 197 enum ip_conntrack_dir dir = CTINFO2DIR(ctinfo);
198 u_int32_t newip; 198 __be32 newip;
199 u_int16_t port; 199 u_int16_t port;
200 200
201 DEBUGP("ip_nat_sdp():\n"); 201 DEBUGP("ip_nat_sdp():\n");
diff --git a/net/ipv4/netfilter/ip_nat_snmp_basic.c b/net/ipv4/netfilter/ip_nat_snmp_basic.c
index 18b7fbdccb61..168f45fa1898 100644
--- a/net/ipv4/netfilter/ip_nat_snmp_basic.c
+++ b/net/ipv4/netfilter/ip_nat_snmp_basic.c
@@ -1211,7 +1211,7 @@ static int snmp_translate(struct ip_conntrack *ct,
1211 struct sk_buff **pskb) 1211 struct sk_buff **pskb)
1212{ 1212{
1213 struct iphdr *iph = (*pskb)->nh.iph; 1213 struct iphdr *iph = (*pskb)->nh.iph;
1214 struct udphdr *udph = (struct udphdr *)((u_int32_t *)iph + iph->ihl); 1214 struct udphdr *udph = (struct udphdr *)((__be32 *)iph + iph->ihl);
1215 u_int16_t udplen = ntohs(udph->len); 1215 u_int16_t udplen = ntohs(udph->len);
1216 u_int16_t paylen = udplen - sizeof(struct udphdr); 1216 u_int16_t paylen = udplen - sizeof(struct udphdr);
1217 int dir = CTINFO2DIR(ctinfo); 1217 int dir = CTINFO2DIR(ctinfo);
diff --git a/net/ipv4/netfilter/ip_nat_standalone.c b/net/ipv4/netfilter/ip_nat_standalone.c
index 9c577db62047..021395b67463 100644
--- a/net/ipv4/netfilter/ip_nat_standalone.c
+++ b/net/ipv4/netfilter/ip_nat_standalone.c
@@ -191,7 +191,7 @@ ip_nat_in(unsigned int hooknum,
191 int (*okfn)(struct sk_buff *)) 191 int (*okfn)(struct sk_buff *))
192{ 192{
193 unsigned int ret; 193 unsigned int ret;
194 u_int32_t daddr = (*pskb)->nh.iph->daddr; 194 __be32 daddr = (*pskb)->nh.iph->daddr;
195 195
196 ret = ip_nat_fn(hooknum, pskb, in, out, okfn); 196 ret = ip_nat_fn(hooknum, pskb, in, out, okfn);
197 if (ret != NF_DROP && ret != NF_STOLEN 197 if (ret != NF_DROP && ret != NF_STOLEN
diff --git a/net/ipv4/netfilter/ipt_CLUSTERIP.c b/net/ipv4/netfilter/ipt_CLUSTERIP.c
index 41589665fc5d..7a29d6e7baa7 100644
--- a/net/ipv4/netfilter/ipt_CLUSTERIP.c
+++ b/net/ipv4/netfilter/ipt_CLUSTERIP.c
@@ -52,7 +52,7 @@ struct clusterip_config {
52 atomic_t entries; /* number of entries/rules 52 atomic_t entries; /* number of entries/rules
53 * referencing us */ 53 * referencing us */
54 54
55 u_int32_t clusterip; /* the IP address */ 55 __be32 clusterip; /* the IP address */
56 u_int8_t clustermac[ETH_ALEN]; /* the MAC address */ 56 u_int8_t clustermac[ETH_ALEN]; /* the MAC address */
57 struct net_device *dev; /* device */ 57 struct net_device *dev; /* device */
58 u_int16_t num_total_nodes; /* total number of nodes */ 58 u_int16_t num_total_nodes; /* total number of nodes */
@@ -119,7 +119,7 @@ clusterip_config_entry_put(struct clusterip_config *c)
119} 119}
120 120
121static struct clusterip_config * 121static struct clusterip_config *
122__clusterip_config_find(u_int32_t clusterip) 122__clusterip_config_find(__be32 clusterip)
123{ 123{
124 struct list_head *pos; 124 struct list_head *pos;
125 125
@@ -136,7 +136,7 @@ __clusterip_config_find(u_int32_t clusterip)
136} 136}
137 137
138static inline struct clusterip_config * 138static inline struct clusterip_config *
139clusterip_config_find_get(u_int32_t clusterip, int entry) 139clusterip_config_find_get(__be32 clusterip, int entry)
140{ 140{
141 struct clusterip_config *c; 141 struct clusterip_config *c;
142 142
@@ -166,7 +166,7 @@ clusterip_config_init_nodelist(struct clusterip_config *c,
166} 166}
167 167
168static struct clusterip_config * 168static struct clusterip_config *
169clusterip_config_init(struct ipt_clusterip_tgt_info *i, u_int32_t ip, 169clusterip_config_init(struct ipt_clusterip_tgt_info *i, __be32 ip,
170 struct net_device *dev) 170 struct net_device *dev)
171{ 171{
172 struct clusterip_config *c; 172 struct clusterip_config *c;
@@ -387,7 +387,7 @@ checkentry(const char *tablename,
387 return 0; 387 return 0;
388 388
389 } 389 }
390 if (e->ip.dmsk.s_addr != 0xffffffff 390 if (e->ip.dmsk.s_addr != htonl(0xffffffff)
391 || e->ip.dst.s_addr == 0) { 391 || e->ip.dst.s_addr == 0) {
392 printk(KERN_ERR "CLUSTERIP: Please specify destination IP\n"); 392 printk(KERN_ERR "CLUSTERIP: Please specify destination IP\n");
393 return 0; 393 return 0;
@@ -476,9 +476,9 @@ static struct ipt_target clusterip_tgt = {
476/* hardcoded for 48bit ethernet and 32bit ipv4 addresses */ 476/* hardcoded for 48bit ethernet and 32bit ipv4 addresses */
477struct arp_payload { 477struct arp_payload {
478 u_int8_t src_hw[ETH_ALEN]; 478 u_int8_t src_hw[ETH_ALEN];
479 u_int32_t src_ip; 479 __be32 src_ip;
480 u_int8_t dst_hw[ETH_ALEN]; 480 u_int8_t dst_hw[ETH_ALEN];
481 u_int32_t dst_ip; 481 __be32 dst_ip;
482} __attribute__ ((packed)); 482} __attribute__ ((packed));
483 483
484#ifdef CLUSTERIP_DEBUG 484#ifdef CLUSTERIP_DEBUG
diff --git a/net/ipv4/netfilter/ipt_ECN.c b/net/ipv4/netfilter/ipt_ECN.c
index 23f9c7ebe7eb..12a818a2462f 100644
--- a/net/ipv4/netfilter/ipt_ECN.c
+++ b/net/ipv4/netfilter/ipt_ECN.c
@@ -28,7 +28,7 @@ static inline int
28set_ect_ip(struct sk_buff **pskb, const struct ipt_ECN_info *einfo) 28set_ect_ip(struct sk_buff **pskb, const struct ipt_ECN_info *einfo)
29{ 29{
30 struct iphdr *iph = (*pskb)->nh.iph; 30 struct iphdr *iph = (*pskb)->nh.iph;
31 u_int16_t oldtos; 31 __be16 oldtos;
32 32
33 if ((iph->tos & IPT_ECN_IP_MASK) != (einfo->ip_ect & IPT_ECN_IP_MASK)) { 33 if ((iph->tos & IPT_ECN_IP_MASK) != (einfo->ip_ect & IPT_ECN_IP_MASK)) {
34 if (!skb_make_writable(pskb, sizeof(struct iphdr))) 34 if (!skb_make_writable(pskb, sizeof(struct iphdr)))
@@ -37,7 +37,7 @@ set_ect_ip(struct sk_buff **pskb, const struct ipt_ECN_info *einfo)
37 oldtos = iph->tos; 37 oldtos = iph->tos;
38 iph->tos &= ~IPT_ECN_IP_MASK; 38 iph->tos &= ~IPT_ECN_IP_MASK;
39 iph->tos |= (einfo->ip_ect & IPT_ECN_IP_MASK); 39 iph->tos |= (einfo->ip_ect & IPT_ECN_IP_MASK);
40 iph->check = nf_csum_update(oldtos ^ 0xFFFF, iph->tos, 40 iph->check = nf_csum_update(oldtos ^ htons(0xFFFF), iph->tos,
41 iph->check); 41 iph->check);
42 } 42 }
43 return 1; 43 return 1;
@@ -48,7 +48,7 @@ static inline int
48set_ect_tcp(struct sk_buff **pskb, const struct ipt_ECN_info *einfo) 48set_ect_tcp(struct sk_buff **pskb, const struct ipt_ECN_info *einfo)
49{ 49{
50 struct tcphdr _tcph, *tcph; 50 struct tcphdr _tcph, *tcph;
51 u_int16_t oldval; 51 __be16 oldval;
52 52
53 /* Not enought header? */ 53 /* Not enought header? */
54 tcph = skb_header_pointer(*pskb, (*pskb)->nh.iph->ihl*4, 54 tcph = skb_header_pointer(*pskb, (*pskb)->nh.iph->ihl*4,
@@ -66,15 +66,15 @@ set_ect_tcp(struct sk_buff **pskb, const struct ipt_ECN_info *einfo)
66 return 0; 66 return 0;
67 tcph = (void *)(*pskb)->nh.iph + (*pskb)->nh.iph->ihl*4; 67 tcph = (void *)(*pskb)->nh.iph + (*pskb)->nh.iph->ihl*4;
68 68
69 oldval = ((u_int16_t *)tcph)[6]; 69 oldval = ((__be16 *)tcph)[6];
70 if (einfo->operation & IPT_ECN_OP_SET_ECE) 70 if (einfo->operation & IPT_ECN_OP_SET_ECE)
71 tcph->ece = einfo->proto.tcp.ece; 71 tcph->ece = einfo->proto.tcp.ece;
72 if (einfo->operation & IPT_ECN_OP_SET_CWR) 72 if (einfo->operation & IPT_ECN_OP_SET_CWR)
73 tcph->cwr = einfo->proto.tcp.cwr; 73 tcph->cwr = einfo->proto.tcp.cwr;
74 74
75 tcph->check = nf_proto_csum_update((*pskb), 75 tcph->check = nf_proto_csum_update((*pskb),
76 oldval ^ 0xFFFF, 76 oldval ^ htons(0xFFFF),
77 ((u_int16_t *)tcph)[6], 77 ((__be16 *)tcph)[6],
78 tcph->check, 0); 78 tcph->check, 0);
79 return 1; 79 return 1;
80} 80}
diff --git a/net/ipv4/netfilter/ipt_MASQUERADE.c b/net/ipv4/netfilter/ipt_MASQUERADE.c
index bc65168a3437..3dbfcfac8a84 100644
--- a/net/ipv4/netfilter/ipt_MASQUERADE.c
+++ b/net/ipv4/netfilter/ipt_MASQUERADE.c
@@ -70,7 +70,7 @@ masquerade_target(struct sk_buff **pskb,
70 const struct ip_nat_multi_range_compat *mr; 70 const struct ip_nat_multi_range_compat *mr;
71 struct ip_nat_range newrange; 71 struct ip_nat_range newrange;
72 struct rtable *rt; 72 struct rtable *rt;
73 u_int32_t newsrc; 73 __be32 newsrc;
74 74
75 IP_NF_ASSERT(hooknum == NF_IP_POST_ROUTING); 75 IP_NF_ASSERT(hooknum == NF_IP_POST_ROUTING);
76 76
diff --git a/net/ipv4/netfilter/ipt_NETMAP.c b/net/ipv4/netfilter/ipt_NETMAP.c
index beb2914225ff..58a88f227108 100644
--- a/net/ipv4/netfilter/ipt_NETMAP.c
+++ b/net/ipv4/netfilter/ipt_NETMAP.c
@@ -58,7 +58,7 @@ target(struct sk_buff **pskb,
58{ 58{
59 struct ip_conntrack *ct; 59 struct ip_conntrack *ct;
60 enum ip_conntrack_info ctinfo; 60 enum ip_conntrack_info ctinfo;
61 u_int32_t new_ip, netmask; 61 __be32 new_ip, netmask;
62 const struct ip_nat_multi_range_compat *mr = targinfo; 62 const struct ip_nat_multi_range_compat *mr = targinfo;
63 struct ip_nat_range newrange; 63 struct ip_nat_range newrange;
64 64
diff --git a/net/ipv4/netfilter/ipt_REDIRECT.c b/net/ipv4/netfilter/ipt_REDIRECT.c
index f03d43671c6d..c0dcfe9d610c 100644
--- a/net/ipv4/netfilter/ipt_REDIRECT.c
+++ b/net/ipv4/netfilter/ipt_REDIRECT.c
@@ -61,7 +61,7 @@ redirect_target(struct sk_buff **pskb,
61{ 61{
62 struct ip_conntrack *ct; 62 struct ip_conntrack *ct;
63 enum ip_conntrack_info ctinfo; 63 enum ip_conntrack_info ctinfo;
64 u_int32_t newdst; 64 __be32 newdst;
65 const struct ip_nat_multi_range_compat *mr = targinfo; 65 const struct ip_nat_multi_range_compat *mr = targinfo;
66 struct ip_nat_range newrange; 66 struct ip_nat_range newrange;
67 67
diff --git a/net/ipv4/netfilter/ipt_REJECT.c b/net/ipv4/netfilter/ipt_REJECT.c
index b81821edd893..fd0c05efed8a 100644
--- a/net/ipv4/netfilter/ipt_REJECT.c
+++ b/net/ipv4/netfilter/ipt_REJECT.c
@@ -104,8 +104,8 @@ static void send_reset(struct sk_buff *oldskb, int hook)
104 struct iphdr *iph = oldskb->nh.iph; 104 struct iphdr *iph = oldskb->nh.iph;
105 struct tcphdr _otcph, *oth, *tcph; 105 struct tcphdr _otcph, *oth, *tcph;
106 struct rtable *rt; 106 struct rtable *rt;
107 u_int16_t tmp_port; 107 __be16 tmp_port;
108 u_int32_t tmp_addr; 108 __be32 tmp_addr;
109 int needs_ack; 109 int needs_ack;
110 int hh_len; 110 int hh_len;
111 111
diff --git a/net/ipv4/netfilter/ipt_SAME.c b/net/ipv4/netfilter/ipt_SAME.c
index efbcb1198832..b38b13328d73 100644
--- a/net/ipv4/netfilter/ipt_SAME.c
+++ b/net/ipv4/netfilter/ipt_SAME.c
@@ -135,7 +135,8 @@ same_target(struct sk_buff **pskb,
135{ 135{
136 struct ip_conntrack *ct; 136 struct ip_conntrack *ct;
137 enum ip_conntrack_info ctinfo; 137 enum ip_conntrack_info ctinfo;
138 u_int32_t tmpip, aindex, new_ip; 138 u_int32_t tmpip, aindex;
139 __be32 new_ip;
139 const struct ipt_same_info *same = targinfo; 140 const struct ipt_same_info *same = targinfo;
140 struct ip_nat_range newrange; 141 struct ip_nat_range newrange;
141 const struct ip_conntrack_tuple *t; 142 const struct ip_conntrack_tuple *t;
diff --git a/net/ipv4/netfilter/ipt_TCPMSS.c b/net/ipv4/netfilter/ipt_TCPMSS.c
index 4246c4321e5b..108b6b76311f 100644
--- a/net/ipv4/netfilter/ipt_TCPMSS.c
+++ b/net/ipv4/netfilter/ipt_TCPMSS.c
@@ -42,7 +42,8 @@ ipt_tcpmss_target(struct sk_buff **pskb,
42 const struct ipt_tcpmss_info *tcpmssinfo = targinfo; 42 const struct ipt_tcpmss_info *tcpmssinfo = targinfo;
43 struct tcphdr *tcph; 43 struct tcphdr *tcph;
44 struct iphdr *iph; 44 struct iphdr *iph;
45 u_int16_t tcplen, newtotlen, oldval, newmss; 45 u_int16_t tcplen, newmss;
46 __be16 newtotlen, oldval;
46 unsigned int i; 47 unsigned int i;
47 u_int8_t *opt; 48 u_int8_t *opt;
48 49
@@ -97,7 +98,7 @@ ipt_tcpmss_target(struct sk_buff **pskb,
97 opt[i+3] = (newmss & 0x00ff); 98 opt[i+3] = (newmss & 0x00ff);
98 99
99 tcph->check = nf_proto_csum_update(*pskb, 100 tcph->check = nf_proto_csum_update(*pskb,
100 htons(oldmss)^0xFFFF, 101 htons(oldmss)^htons(0xFFFF),
101 htons(newmss), 102 htons(newmss),
102 tcph->check, 0); 103 tcph->check, 0);
103 return IPT_CONTINUE; 104 return IPT_CONTINUE;
@@ -126,7 +127,7 @@ ipt_tcpmss_target(struct sk_buff **pskb,
126 memmove(opt + TCPOLEN_MSS, opt, tcplen - sizeof(struct tcphdr)); 127 memmove(opt + TCPOLEN_MSS, opt, tcplen - sizeof(struct tcphdr));
127 128
128 tcph->check = nf_proto_csum_update(*pskb, 129 tcph->check = nf_proto_csum_update(*pskb,
129 htons(tcplen) ^ 0xFFFF, 130 htons(tcplen) ^ htons(0xFFFF),
130 htons(tcplen + TCPOLEN_MSS), 131 htons(tcplen + TCPOLEN_MSS),
131 tcph->check, 1); 132 tcph->check, 1);
132 opt[0] = TCPOPT_MSS; 133 opt[0] = TCPOPT_MSS;
@@ -134,18 +135,18 @@ ipt_tcpmss_target(struct sk_buff **pskb,
134 opt[2] = (newmss & 0xff00) >> 8; 135 opt[2] = (newmss & 0xff00) >> 8;
135 opt[3] = (newmss & 0x00ff); 136 opt[3] = (newmss & 0x00ff);
136 137
137 tcph->check = nf_proto_csum_update(*pskb, ~0, *((u_int32_t *)opt), 138 tcph->check = nf_proto_csum_update(*pskb, htonl(~0), *((__be32 *)opt),
138 tcph->check, 0); 139 tcph->check, 0);
139 140
140 oldval = ((u_int16_t *)tcph)[6]; 141 oldval = ((__be16 *)tcph)[6];
141 tcph->doff += TCPOLEN_MSS/4; 142 tcph->doff += TCPOLEN_MSS/4;
142 tcph->check = nf_proto_csum_update(*pskb, 143 tcph->check = nf_proto_csum_update(*pskb,
143 oldval ^ 0xFFFF, 144 oldval ^ htons(0xFFFF),
144 ((u_int16_t *)tcph)[6], 145 ((__be16 *)tcph)[6],
145 tcph->check, 0); 146 tcph->check, 0);
146 147
147 newtotlen = htons(ntohs(iph->tot_len) + TCPOLEN_MSS); 148 newtotlen = htons(ntohs(iph->tot_len) + TCPOLEN_MSS);
148 iph->check = nf_csum_update(iph->tot_len ^ 0xFFFF, 149 iph->check = nf_csum_update(iph->tot_len ^ htons(0xFFFF),
149 newtotlen, iph->check); 150 newtotlen, iph->check);
150 iph->tot_len = newtotlen; 151 iph->tot_len = newtotlen;
151 return IPT_CONTINUE; 152 return IPT_CONTINUE;
diff --git a/net/ipv4/netfilter/ipt_TOS.c b/net/ipv4/netfilter/ipt_TOS.c
index 471a4c438b0a..6b8b14ccc3d3 100644
--- a/net/ipv4/netfilter/ipt_TOS.c
+++ b/net/ipv4/netfilter/ipt_TOS.c
@@ -30,7 +30,7 @@ target(struct sk_buff **pskb,
30{ 30{
31 const struct ipt_tos_target_info *tosinfo = targinfo; 31 const struct ipt_tos_target_info *tosinfo = targinfo;
32 struct iphdr *iph = (*pskb)->nh.iph; 32 struct iphdr *iph = (*pskb)->nh.iph;
33 u_int16_t oldtos; 33 __be16 oldtos;
34 34
35 if ((iph->tos & IPTOS_TOS_MASK) != tosinfo->tos) { 35 if ((iph->tos & IPTOS_TOS_MASK) != tosinfo->tos) {
36 if (!skb_make_writable(pskb, sizeof(struct iphdr))) 36 if (!skb_make_writable(pskb, sizeof(struct iphdr)))
@@ -38,7 +38,7 @@ target(struct sk_buff **pskb,
38 iph = (*pskb)->nh.iph; 38 iph = (*pskb)->nh.iph;
39 oldtos = iph->tos; 39 oldtos = iph->tos;
40 iph->tos = (iph->tos & IPTOS_PREC_MASK) | tosinfo->tos; 40 iph->tos = (iph->tos & IPTOS_PREC_MASK) | tosinfo->tos;
41 iph->check = nf_csum_update(oldtos ^ 0xFFFF, iph->tos, 41 iph->check = nf_csum_update(oldtos ^ htons(0xFFFF), iph->tos,
42 iph->check); 42 iph->check);
43 } 43 }
44 return IPT_CONTINUE; 44 return IPT_CONTINUE;
diff --git a/net/ipv4/netfilter/ipt_TTL.c b/net/ipv4/netfilter/ipt_TTL.c
index 96e79cc6d0f2..ac9517d62af0 100644
--- a/net/ipv4/netfilter/ipt_TTL.c
+++ b/net/ipv4/netfilter/ipt_TTL.c
@@ -54,8 +54,8 @@ ipt_ttl_target(struct sk_buff **pskb,
54 } 54 }
55 55
56 if (new_ttl != iph->ttl) { 56 if (new_ttl != iph->ttl) {
57 iph->check = nf_csum_update(ntohs((iph->ttl << 8)) ^ 0xFFFF, 57 iph->check = nf_csum_update(htons((iph->ttl << 8)) ^ htons(0xFFFF),
58 ntohs(new_ttl << 8), 58 htons(new_ttl << 8),
59 iph->check); 59 iph->check);
60 iph->ttl = new_ttl; 60 iph->ttl = new_ttl;
61 } 61 }
diff --git a/net/ipv4/netfilter/ipt_addrtype.c b/net/ipv4/netfilter/ipt_addrtype.c
index 893dae210b04..7b60eb74788b 100644
--- a/net/ipv4/netfilter/ipt_addrtype.c
+++ b/net/ipv4/netfilter/ipt_addrtype.c
@@ -22,7 +22,7 @@ MODULE_LICENSE("GPL");
22MODULE_AUTHOR("Patrick McHardy <kaber@trash.net>"); 22MODULE_AUTHOR("Patrick McHardy <kaber@trash.net>");
23MODULE_DESCRIPTION("iptables addrtype match"); 23MODULE_DESCRIPTION("iptables addrtype match");
24 24
25static inline int match_type(u_int32_t addr, u_int16_t mask) 25static inline int match_type(__be32 addr, u_int16_t mask)
26{ 26{
27 return !!(mask & (1 << inet_addr_type(addr))); 27 return !!(mask & (1 << inet_addr_type(addr)));
28} 28}
diff --git a/net/ipv4/netfilter/ipt_hashlimit.c b/net/ipv4/netfilter/ipt_hashlimit.c
index 4f73a61aa3dd..33ccdbf8e794 100644
--- a/net/ipv4/netfilter/ipt_hashlimit.c
+++ b/net/ipv4/netfilter/ipt_hashlimit.c
@@ -50,11 +50,11 @@ static struct file_operations dl_file_ops;
50/* hash table crap */ 50/* hash table crap */
51 51
52struct dsthash_dst { 52struct dsthash_dst {
53 u_int32_t src_ip; 53 __be32 src_ip;
54 u_int32_t dst_ip; 54 __be32 dst_ip;
55 /* ports have to be consecutive !!! */ 55 /* ports have to be consecutive !!! */
56 u_int16_t src_port; 56 __be16 src_port;
57 u_int16_t dst_port; 57 __be16 dst_port;
58}; 58};
59 59
60struct dsthash_ent { 60struct dsthash_ent {
@@ -106,8 +106,10 @@ static inline int dst_cmp(const struct dsthash_ent *ent, struct dsthash_dst *b)
106static inline u_int32_t 106static inline u_int32_t
107hash_dst(const struct ipt_hashlimit_htable *ht, const struct dsthash_dst *dst) 107hash_dst(const struct ipt_hashlimit_htable *ht, const struct dsthash_dst *dst)
108{ 108{
109 return (jhash_3words(dst->dst_ip, (dst->dst_port<<16 | dst->src_port), 109 return (jhash_3words((__force u32)dst->dst_ip,
110 dst->src_ip, ht->rnd) % ht->cfg.size); 110 ((__force u32)dst->dst_port<<16 |
111 (__force u32)dst->src_port),
112 (__force u32)dst->src_ip, ht->rnd) % ht->cfg.size);
111} 113}
112 114
113static inline struct dsthash_ent * 115static inline struct dsthash_ent *
@@ -406,7 +408,7 @@ hashlimit_match(const struct sk_buff *skb,
406 dst.src_ip = skb->nh.iph->saddr; 408 dst.src_ip = skb->nh.iph->saddr;
407 if (hinfo->cfg.mode & IPT_HASHLIMIT_HASH_DPT 409 if (hinfo->cfg.mode & IPT_HASHLIMIT_HASH_DPT
408 ||hinfo->cfg.mode & IPT_HASHLIMIT_HASH_SPT) { 410 ||hinfo->cfg.mode & IPT_HASHLIMIT_HASH_SPT) {
409 u_int16_t _ports[2], *ports; 411 __be16 _ports[2], *ports;
410 412
411 switch (skb->nh.iph->protocol) { 413 switch (skb->nh.iph->protocol) {
412 case IPPROTO_TCP: 414 case IPPROTO_TCP:
diff --git a/net/ipv4/netfilter/ipt_recent.c b/net/ipv4/netfilter/ipt_recent.c
index 32ae8d7ac506..126db44e71a8 100644
--- a/net/ipv4/netfilter/ipt_recent.c
+++ b/net/ipv4/netfilter/ipt_recent.c
@@ -50,11 +50,10 @@ MODULE_PARM_DESC(ip_list_perms, "permissions on /proc/net/ipt_recent/* files");
50MODULE_PARM_DESC(ip_list_uid,"owner of /proc/net/ipt_recent/* files"); 50MODULE_PARM_DESC(ip_list_uid,"owner of /proc/net/ipt_recent/* files");
51MODULE_PARM_DESC(ip_list_gid,"owning group of /proc/net/ipt_recent/* files"); 51MODULE_PARM_DESC(ip_list_gid,"owning group of /proc/net/ipt_recent/* files");
52 52
53
54struct recent_entry { 53struct recent_entry {
55 struct list_head list; 54 struct list_head list;
56 struct list_head lru_list; 55 struct list_head lru_list;
57 u_int32_t addr; 56 __be32 addr;
58 u_int8_t ttl; 57 u_int8_t ttl;
59 u_int8_t index; 58 u_int8_t index;
60 u_int16_t nstamps; 59 u_int16_t nstamps;
@@ -85,17 +84,17 @@ static struct file_operations recent_fops;
85static u_int32_t hash_rnd; 84static u_int32_t hash_rnd;
86static int hash_rnd_initted; 85static int hash_rnd_initted;
87 86
88static unsigned int recent_entry_hash(u_int32_t addr) 87static unsigned int recent_entry_hash(__be32 addr)
89{ 88{
90 if (!hash_rnd_initted) { 89 if (!hash_rnd_initted) {
91 get_random_bytes(&hash_rnd, 4); 90 get_random_bytes(&hash_rnd, 4);
92 hash_rnd_initted = 1; 91 hash_rnd_initted = 1;
93 } 92 }
94 return jhash_1word(addr, hash_rnd) & (ip_list_hash_size - 1); 93 return jhash_1word((__force u32)addr, hash_rnd) & (ip_list_hash_size - 1);
95} 94}
96 95
97static struct recent_entry * 96static struct recent_entry *
98recent_entry_lookup(const struct recent_table *table, u_int32_t addr, u_int8_t ttl) 97recent_entry_lookup(const struct recent_table *table, __be32 addr, u_int8_t ttl)
99{ 98{
100 struct recent_entry *e; 99 struct recent_entry *e;
101 unsigned int h; 100 unsigned int h;
@@ -116,7 +115,7 @@ static void recent_entry_remove(struct recent_table *t, struct recent_entry *e)
116} 115}
117 116
118static struct recent_entry * 117static struct recent_entry *
119recent_entry_init(struct recent_table *t, u_int32_t addr, u_int8_t ttl) 118recent_entry_init(struct recent_table *t, __be32 addr, u_int8_t ttl)
120{ 119{
121 struct recent_entry *e; 120 struct recent_entry *e;
122 121
@@ -178,7 +177,7 @@ ipt_recent_match(const struct sk_buff *skb,
178 const struct ipt_recent_info *info = matchinfo; 177 const struct ipt_recent_info *info = matchinfo;
179 struct recent_table *t; 178 struct recent_table *t;
180 struct recent_entry *e; 179 struct recent_entry *e;
181 u_int32_t addr; 180 __be32 addr;
182 u_int8_t ttl; 181 u_int8_t ttl;
183 int ret = info->invert; 182 int ret = info->invert;
184 183
@@ -406,7 +405,7 @@ static ssize_t recent_proc_write(struct file *file, const char __user *input,
406 struct recent_table *t = pde->data; 405 struct recent_table *t = pde->data;
407 struct recent_entry *e; 406 struct recent_entry *e;
408 char buf[sizeof("+255.255.255.255")], *c = buf; 407 char buf[sizeof("+255.255.255.255")], *c = buf;
409 u_int32_t addr; 408 __be32 addr;
410 int add; 409 int add;
411 410
412 if (size > sizeof(buf)) 411 if (size > sizeof(buf))
diff --git a/net/ipv4/netfilter/iptable_mangle.c b/net/ipv4/netfilter/iptable_mangle.c
index 79336cb42527..e62ea2bb9c0a 100644
--- a/net/ipv4/netfilter/iptable_mangle.c
+++ b/net/ipv4/netfilter/iptable_mangle.c
@@ -131,7 +131,7 @@ ipt_local_hook(unsigned int hook,
131{ 131{
132 unsigned int ret; 132 unsigned int ret;
133 u_int8_t tos; 133 u_int8_t tos;
134 u_int32_t saddr, daddr; 134 __be32 saddr, daddr;
135 unsigned long nfmark; 135 unsigned long nfmark;
136 136
137 /* root is playing with raw sockets. */ 137 /* root is playing with raw sockets. */
diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
index 0e935b4c8741..b430cf2a4f66 100644
--- a/net/ipv4/raw.c
+++ b/net/ipv4/raw.c
@@ -381,8 +381,8 @@ static int raw_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
381 struct ipcm_cookie ipc; 381 struct ipcm_cookie ipc;
382 struct rtable *rt = NULL; 382 struct rtable *rt = NULL;
383 int free = 0; 383 int free = 0;
384 u32 daddr; 384 __be32 daddr;
385 u32 saddr; 385 __be32 saddr;
386 u8 tos; 386 u8 tos;
387 int err; 387 int err;
388 388
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index 20ffe8e88c0f..c41ddba02e9d 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -261,6 +261,10 @@ static unsigned int rt_hash_code(u32 daddr, u32 saddr)
261 & rt_hash_mask); 261 & rt_hash_mask);
262} 262}
263 263
264#define rt_hash(daddr, saddr, idx) \
265 rt_hash_code((__force u32)(__be32)(daddr),\
266 (__force u32)(__be32)(saddr) ^ ((idx) << 5))
267
264#ifdef CONFIG_PROC_FS 268#ifdef CONFIG_PROC_FS
265struct rt_cache_iter_state { 269struct rt_cache_iter_state {
266 int bucket; 270 int bucket;
@@ -1074,7 +1078,7 @@ static void ip_select_fb_ident(struct iphdr *iph)
1074 u32 salt; 1078 u32 salt;
1075 1079
1076 spin_lock_bh(&ip_fb_id_lock); 1080 spin_lock_bh(&ip_fb_id_lock);
1077 salt = secure_ip_id(ip_fallback_id ^ iph->daddr); 1081 salt = secure_ip_id((__force __be32)ip_fallback_id ^ iph->daddr);
1078 iph->id = htons(salt & 0xFFFF); 1082 iph->id = htons(salt & 0xFFFF);
1079 ip_fallback_id = salt; 1083 ip_fallback_id = salt;
1080 spin_unlock_bh(&ip_fb_id_lock); 1084 spin_unlock_bh(&ip_fb_id_lock);
@@ -1118,13 +1122,13 @@ static void rt_del(unsigned hash, struct rtable *rt)
1118 spin_unlock_bh(rt_hash_lock_addr(hash)); 1122 spin_unlock_bh(rt_hash_lock_addr(hash));
1119} 1123}
1120 1124
1121void ip_rt_redirect(u32 old_gw, u32 daddr, u32 new_gw, 1125void ip_rt_redirect(__be32 old_gw, __be32 daddr, __be32 new_gw,
1122 u32 saddr, struct net_device *dev) 1126 __be32 saddr, struct net_device *dev)
1123{ 1127{
1124 int i, k; 1128 int i, k;
1125 struct in_device *in_dev = in_dev_get(dev); 1129 struct in_device *in_dev = in_dev_get(dev);
1126 struct rtable *rth, **rthp; 1130 struct rtable *rth, **rthp;
1127 u32 skeys[2] = { saddr, 0 }; 1131 __be32 skeys[2] = { saddr, 0 };
1128 int ikeys[2] = { dev->ifindex, 0 }; 1132 int ikeys[2] = { dev->ifindex, 0 };
1129 struct netevent_redirect netevent; 1133 struct netevent_redirect netevent;
1130 1134
@@ -1147,8 +1151,7 @@ void ip_rt_redirect(u32 old_gw, u32 daddr, u32 new_gw,
1147 1151
1148 for (i = 0; i < 2; i++) { 1152 for (i = 0; i < 2; i++) {
1149 for (k = 0; k < 2; k++) { 1153 for (k = 0; k < 2; k++) {
1150 unsigned hash = rt_hash_code(daddr, 1154 unsigned hash = rt_hash(daddr, skeys[i], ikeys[k]);
1151 skeys[i] ^ (ikeys[k] << 5));
1152 1155
1153 rthp=&rt_hash_table[hash].chain; 1156 rthp=&rt_hash_table[hash].chain;
1154 1157
@@ -1260,9 +1263,8 @@ static struct dst_entry *ipv4_negative_advice(struct dst_entry *dst)
1260 ret = NULL; 1263 ret = NULL;
1261 } else if ((rt->rt_flags & RTCF_REDIRECTED) || 1264 } else if ((rt->rt_flags & RTCF_REDIRECTED) ||
1262 rt->u.dst.expires) { 1265 rt->u.dst.expires) {
1263 unsigned hash = rt_hash_code(rt->fl.fl4_dst, 1266 unsigned hash = rt_hash(rt->fl.fl4_dst, rt->fl.fl4_src,
1264 rt->fl.fl4_src ^ 1267 rt->fl.oif);
1265 (rt->fl.oif << 5));
1266#if RT_CACHE_DEBUG >= 1 1268#if RT_CACHE_DEBUG >= 1
1267 printk(KERN_DEBUG "ip_rt_advice: redirect to " 1269 printk(KERN_DEBUG "ip_rt_advice: redirect to "
1268 "%u.%u.%u.%u/%02x dropped\n", 1270 "%u.%u.%u.%u/%02x dropped\n",
@@ -1397,15 +1399,15 @@ unsigned short ip_rt_frag_needed(struct iphdr *iph, unsigned short new_mtu)
1397 int i; 1399 int i;
1398 unsigned short old_mtu = ntohs(iph->tot_len); 1400 unsigned short old_mtu = ntohs(iph->tot_len);
1399 struct rtable *rth; 1401 struct rtable *rth;
1400 u32 skeys[2] = { iph->saddr, 0, }; 1402 __be32 skeys[2] = { iph->saddr, 0, };
1401 u32 daddr = iph->daddr; 1403 __be32 daddr = iph->daddr;
1402 unsigned short est_mtu = 0; 1404 unsigned short est_mtu = 0;
1403 1405
1404 if (ipv4_config.no_pmtu_disc) 1406 if (ipv4_config.no_pmtu_disc)
1405 return 0; 1407 return 0;
1406 1408
1407 for (i = 0; i < 2; i++) { 1409 for (i = 0; i < 2; i++) {
1408 unsigned hash = rt_hash_code(daddr, skeys[i]); 1410 unsigned hash = rt_hash(daddr, skeys[i], 0);
1409 1411
1410 rcu_read_lock(); 1412 rcu_read_lock();
1411 for (rth = rcu_dereference(rt_hash_table[hash].chain); rth; 1413 for (rth = rcu_dereference(rt_hash_table[hash].chain); rth;
@@ -1530,7 +1532,7 @@ static int ip_rt_bug(struct sk_buff *skb)
1530 1532
1531void ip_rt_get_source(u8 *addr, struct rtable *rt) 1533void ip_rt_get_source(u8 *addr, struct rtable *rt)
1532{ 1534{
1533 u32 src; 1535 __be32 src;
1534 struct fib_result res; 1536 struct fib_result res;
1535 1537
1536 if (rt->fl.iif == 0) 1538 if (rt->fl.iif == 0)
@@ -1596,12 +1598,12 @@ static void rt_set_nexthop(struct rtable *rt, struct fib_result *res, u32 itag)
1596 rt->rt_type = res->type; 1598 rt->rt_type = res->type;
1597} 1599}
1598 1600
1599static int ip_route_input_mc(struct sk_buff *skb, u32 daddr, u32 saddr, 1601static int ip_route_input_mc(struct sk_buff *skb, __be32 daddr, __be32 saddr,
1600 u8 tos, struct net_device *dev, int our) 1602 u8 tos, struct net_device *dev, int our)
1601{ 1603{
1602 unsigned hash; 1604 unsigned hash;
1603 struct rtable *rth; 1605 struct rtable *rth;
1604 u32 spec_dst; 1606 __be32 spec_dst;
1605 struct in_device *in_dev = in_dev_get(dev); 1607 struct in_device *in_dev = in_dev_get(dev);
1606 u32 itag = 0; 1608 u32 itag = 0;
1607 1609
@@ -1665,7 +1667,7 @@ static int ip_route_input_mc(struct sk_buff *skb, u32 daddr, u32 saddr,
1665 RT_CACHE_STAT_INC(in_slow_mc); 1667 RT_CACHE_STAT_INC(in_slow_mc);
1666 1668
1667 in_dev_put(in_dev); 1669 in_dev_put(in_dev);
1668 hash = rt_hash_code(daddr, saddr ^ (dev->ifindex << 5)); 1670 hash = rt_hash(daddr, saddr, dev->ifindex);
1669 return rt_intern_hash(hash, rth, (struct rtable**) &skb->dst); 1671 return rt_intern_hash(hash, rth, (struct rtable**) &skb->dst);
1670 1672
1671e_nobufs: 1673e_nobufs:
@@ -1681,8 +1683,8 @@ e_inval:
1681static void ip_handle_martian_source(struct net_device *dev, 1683static void ip_handle_martian_source(struct net_device *dev,
1682 struct in_device *in_dev, 1684 struct in_device *in_dev,
1683 struct sk_buff *skb, 1685 struct sk_buff *skb,
1684 u32 daddr, 1686 __be32 daddr,
1685 u32 saddr) 1687 __be32 saddr)
1686{ 1688{
1687 RT_CACHE_STAT_INC(in_martian_src); 1689 RT_CACHE_STAT_INC(in_martian_src);
1688#ifdef CONFIG_IP_ROUTE_VERBOSE 1690#ifdef CONFIG_IP_ROUTE_VERBOSE
@@ -1712,7 +1714,7 @@ static void ip_handle_martian_source(struct net_device *dev,
1712static inline int __mkroute_input(struct sk_buff *skb, 1714static inline int __mkroute_input(struct sk_buff *skb,
1713 struct fib_result* res, 1715 struct fib_result* res,
1714 struct in_device *in_dev, 1716 struct in_device *in_dev,
1715 u32 daddr, u32 saddr, u32 tos, 1717 __be32 daddr, __be32 saddr, u32 tos,
1716 struct rtable **result) 1718 struct rtable **result)
1717{ 1719{
1718 1720
@@ -1720,7 +1722,8 @@ static inline int __mkroute_input(struct sk_buff *skb,
1720 int err; 1722 int err;
1721 struct in_device *out_dev; 1723 struct in_device *out_dev;
1722 unsigned flags = 0; 1724 unsigned flags = 0;
1723 u32 spec_dst, itag; 1725 __be32 spec_dst;
1726 u32 itag;
1724 1727
1725 /* get a working reference to the output device */ 1728 /* get a working reference to the output device */
1726 out_dev = in_dev_get(FIB_RES_DEV(*res)); 1729 out_dev = in_dev_get(FIB_RES_DEV(*res));
@@ -1813,7 +1816,7 @@ static inline int ip_mkroute_input_def(struct sk_buff *skb,
1813 struct fib_result* res, 1816 struct fib_result* res,
1814 const struct flowi *fl, 1817 const struct flowi *fl,
1815 struct in_device *in_dev, 1818 struct in_device *in_dev,
1816 u32 daddr, u32 saddr, u32 tos) 1819 __be32 daddr, __be32 saddr, u32 tos)
1817{ 1820{
1818 struct rtable* rth = NULL; 1821 struct rtable* rth = NULL;
1819 int err; 1822 int err;
@@ -1830,7 +1833,7 @@ static inline int ip_mkroute_input_def(struct sk_buff *skb,
1830 return err; 1833 return err;
1831 1834
1832 /* put it into the cache */ 1835 /* put it into the cache */
1833 hash = rt_hash_code(daddr, saddr ^ (fl->iif << 5)); 1836 hash = rt_hash(daddr, saddr, fl->iif);
1834 return rt_intern_hash(hash, rth, (struct rtable**)&skb->dst); 1837 return rt_intern_hash(hash, rth, (struct rtable**)&skb->dst);
1835} 1838}
1836 1839
@@ -1838,7 +1841,7 @@ static inline int ip_mkroute_input(struct sk_buff *skb,
1838 struct fib_result* res, 1841 struct fib_result* res,
1839 const struct flowi *fl, 1842 const struct flowi *fl,
1840 struct in_device *in_dev, 1843 struct in_device *in_dev,
1841 u32 daddr, u32 saddr, u32 tos) 1844 __be32 daddr, __be32 saddr, u32 tos)
1842{ 1845{
1843#ifdef CONFIG_IP_ROUTE_MULTIPATH_CACHED 1846#ifdef CONFIG_IP_ROUTE_MULTIPATH_CACHED
1844 struct rtable* rth = NULL, *rtres; 1847 struct rtable* rth = NULL, *rtres;
@@ -1871,7 +1874,7 @@ static inline int ip_mkroute_input(struct sk_buff *skb,
1871 return err; 1874 return err;
1872 1875
1873 /* put it into the cache */ 1876 /* put it into the cache */
1874 hash = rt_hash_code(daddr, saddr ^ (fl->iif << 5)); 1877 hash = rt_hash(daddr, saddr, fl->iif);
1875 err = rt_intern_hash(hash, rth, &rtres); 1878 err = rt_intern_hash(hash, rth, &rtres);
1876 if (err) 1879 if (err)
1877 return err; 1880 return err;
@@ -1901,7 +1904,7 @@ static inline int ip_mkroute_input(struct sk_buff *skb,
1901 * 2. IP spoofing attempts are filtered with 100% of guarantee. 1904 * 2. IP spoofing attempts are filtered with 100% of guarantee.
1902 */ 1905 */
1903 1906
1904static int ip_route_input_slow(struct sk_buff *skb, u32 daddr, u32 saddr, 1907static int ip_route_input_slow(struct sk_buff *skb, __be32 daddr, __be32 saddr,
1905 u8 tos, struct net_device *dev) 1908 u8 tos, struct net_device *dev)
1906{ 1909{
1907 struct fib_result res; 1910 struct fib_result res;
@@ -1920,7 +1923,7 @@ static int ip_route_input_slow(struct sk_buff *skb, u32 daddr, u32 saddr,
1920 u32 itag = 0; 1923 u32 itag = 0;
1921 struct rtable * rth; 1924 struct rtable * rth;
1922 unsigned hash; 1925 unsigned hash;
1923 u32 spec_dst; 1926 __be32 spec_dst;
1924 int err = -EINVAL; 1927 int err = -EINVAL;
1925 int free_res = 0; 1928 int free_res = 0;
1926 1929
@@ -1936,7 +1939,7 @@ static int ip_route_input_slow(struct sk_buff *skb, u32 daddr, u32 saddr,
1936 if (MULTICAST(saddr) || BADCLASS(saddr) || LOOPBACK(saddr)) 1939 if (MULTICAST(saddr) || BADCLASS(saddr) || LOOPBACK(saddr))
1937 goto martian_source; 1940 goto martian_source;
1938 1941
1939 if (daddr == 0xFFFFFFFF || (saddr == 0 && daddr == 0)) 1942 if (daddr == htonl(0xFFFFFFFF) || (saddr == 0 && daddr == 0))
1940 goto brd_input; 1943 goto brd_input;
1941 1944
1942 /* Accept zero addresses only to limited broadcast; 1945 /* Accept zero addresses only to limited broadcast;
@@ -2048,7 +2051,7 @@ local_input:
2048 rth->rt_flags &= ~RTCF_LOCAL; 2051 rth->rt_flags &= ~RTCF_LOCAL;
2049 } 2052 }
2050 rth->rt_type = res.type; 2053 rth->rt_type = res.type;
2051 hash = rt_hash_code(daddr, saddr ^ (fl.iif << 5)); 2054 hash = rt_hash(daddr, saddr, fl.iif);
2052 err = rt_intern_hash(hash, rth, (struct rtable**)&skb->dst); 2055 err = rt_intern_hash(hash, rth, (struct rtable**)&skb->dst);
2053 goto done; 2056 goto done;
2054 2057
@@ -2087,7 +2090,7 @@ martian_source:
2087 goto e_inval; 2090 goto e_inval;
2088} 2091}
2089 2092
2090int ip_route_input(struct sk_buff *skb, u32 daddr, u32 saddr, 2093int ip_route_input(struct sk_buff *skb, __be32 daddr, __be32 saddr,
2091 u8 tos, struct net_device *dev) 2094 u8 tos, struct net_device *dev)
2092{ 2095{
2093 struct rtable * rth; 2096 struct rtable * rth;
@@ -2095,7 +2098,7 @@ int ip_route_input(struct sk_buff *skb, u32 daddr, u32 saddr,
2095 int iif = dev->ifindex; 2098 int iif = dev->ifindex;
2096 2099
2097 tos &= IPTOS_RT_MASK; 2100 tos &= IPTOS_RT_MASK;
2098 hash = rt_hash_code(daddr, saddr ^ (iif << 5)); 2101 hash = rt_hash(daddr, saddr, iif);
2099 2102
2100 rcu_read_lock(); 2103 rcu_read_lock();
2101 for (rth = rcu_dereference(rt_hash_table[hash].chain); rth; 2104 for (rth = rcu_dereference(rt_hash_table[hash].chain); rth;
@@ -2169,7 +2172,7 @@ static inline int __mkroute_output(struct rtable **result,
2169 if (LOOPBACK(fl->fl4_src) && !(dev_out->flags&IFF_LOOPBACK)) 2172 if (LOOPBACK(fl->fl4_src) && !(dev_out->flags&IFF_LOOPBACK))
2170 return -EINVAL; 2173 return -EINVAL;
2171 2174
2172 if (fl->fl4_dst == 0xFFFFFFFF) 2175 if (fl->fl4_dst == htonl(0xFFFFFFFF))
2173 res->type = RTN_BROADCAST; 2176 res->type = RTN_BROADCAST;
2174 else if (MULTICAST(fl->fl4_dst)) 2177 else if (MULTICAST(fl->fl4_dst))
2175 res->type = RTN_MULTICAST; 2178 res->type = RTN_MULTICAST;
@@ -2293,8 +2296,7 @@ static inline int ip_mkroute_output_def(struct rtable **rp,
2293 int err = __mkroute_output(&rth, res, fl, oldflp, dev_out, flags); 2296 int err = __mkroute_output(&rth, res, fl, oldflp, dev_out, flags);
2294 unsigned hash; 2297 unsigned hash;
2295 if (err == 0) { 2298 if (err == 0) {
2296 hash = rt_hash_code(oldflp->fl4_dst, 2299 hash = rt_hash(oldflp->fl4_dst, oldflp->fl4_src, oldflp->oif);
2297 oldflp->fl4_src ^ (oldflp->oif << 5));
2298 err = rt_intern_hash(hash, rth, rp); 2300 err = rt_intern_hash(hash, rth, rp);
2299 } 2301 }
2300 2302
@@ -2336,9 +2338,8 @@ static inline int ip_mkroute_output(struct rtable** rp,
2336 if (err != 0) 2338 if (err != 0)
2337 goto cleanup; 2339 goto cleanup;
2338 2340
2339 hash = rt_hash_code(oldflp->fl4_dst, 2341 hash = rt_hash(oldflp->fl4_dst, oldflp->fl4_src,
2340 oldflp->fl4_src ^ 2342 oldflp->oif);
2341 (oldflp->oif << 5));
2342 err = rt_intern_hash(hash, rth, rp); 2343 err = rt_intern_hash(hash, rth, rp);
2343 2344
2344 /* forward hop information to multipath impl. */ 2345 /* forward hop information to multipath impl. */
@@ -2417,7 +2418,7 @@ static int ip_route_output_slow(struct rtable **rp, const struct flowi *oldflp)
2417 */ 2418 */
2418 2419
2419 if (oldflp->oif == 0 2420 if (oldflp->oif == 0
2420 && (MULTICAST(oldflp->fl4_dst) || oldflp->fl4_dst == 0xFFFFFFFF)) { 2421 && (MULTICAST(oldflp->fl4_dst) || oldflp->fl4_dst == htonl(0xFFFFFFFF))) {
2421 /* Special hack: user can direct multicasts 2422 /* Special hack: user can direct multicasts
2422 and limited broadcast via necessary interface 2423 and limited broadcast via necessary interface
2423 without fiddling with IP_MULTICAST_IF or IP_PKTINFO. 2424 without fiddling with IP_MULTICAST_IF or IP_PKTINFO.
@@ -2454,7 +2455,7 @@ static int ip_route_output_slow(struct rtable **rp, const struct flowi *oldflp)
2454 goto out; /* Wrong error code */ 2455 goto out; /* Wrong error code */
2455 } 2456 }
2456 2457
2457 if (LOCAL_MCAST(oldflp->fl4_dst) || oldflp->fl4_dst == 0xFFFFFFFF) { 2458 if (LOCAL_MCAST(oldflp->fl4_dst) || oldflp->fl4_dst == htonl(0xFFFFFFFF)) {
2458 if (!fl.fl4_src) 2459 if (!fl.fl4_src)
2459 fl.fl4_src = inet_select_addr(dev_out, 0, 2460 fl.fl4_src = inet_select_addr(dev_out, 0,
2460 RT_SCOPE_LINK); 2461 RT_SCOPE_LINK);
@@ -2567,7 +2568,7 @@ int __ip_route_output_key(struct rtable **rp, const struct flowi *flp)
2567 unsigned hash; 2568 unsigned hash;
2568 struct rtable *rth; 2569 struct rtable *rth;
2569 2570
2570 hash = rt_hash_code(flp->fl4_dst, flp->fl4_src ^ (flp->oif << 5)); 2571 hash = rt_hash(flp->fl4_dst, flp->fl4_src, flp->oif);
2571 2572
2572 rcu_read_lock_bh(); 2573 rcu_read_lock_bh();
2573 for (rth = rcu_dereference(rt_hash_table[hash].chain); rth; 2574 for (rth = rcu_dereference(rt_hash_table[hash].chain); rth;
@@ -2660,11 +2661,11 @@ static int rt_fill_info(struct sk_buff *skb, u32 pid, u32 seq, int event,
2660 if (rt->rt_flags & RTCF_NOTIFY) 2661 if (rt->rt_flags & RTCF_NOTIFY)
2661 r->rtm_flags |= RTM_F_NOTIFY; 2662 r->rtm_flags |= RTM_F_NOTIFY;
2662 2663
2663 NLA_PUT_U32(skb, RTA_DST, rt->rt_dst); 2664 NLA_PUT_BE32(skb, RTA_DST, rt->rt_dst);
2664 2665
2665 if (rt->fl.fl4_src) { 2666 if (rt->fl.fl4_src) {
2666 r->rtm_src_len = 32; 2667 r->rtm_src_len = 32;
2667 NLA_PUT_U32(skb, RTA_SRC, rt->fl.fl4_src); 2668 NLA_PUT_BE32(skb, RTA_SRC, rt->fl.fl4_src);
2668 } 2669 }
2669 if (rt->u.dst.dev) 2670 if (rt->u.dst.dev)
2670 NLA_PUT_U32(skb, RTA_OIF, rt->u.dst.dev->ifindex); 2671 NLA_PUT_U32(skb, RTA_OIF, rt->u.dst.dev->ifindex);
@@ -2677,12 +2678,12 @@ static int rt_fill_info(struct sk_buff *skb, u32 pid, u32 seq, int event,
2677 NLA_PUT_U32(skb, RTA_MP_ALGO, rt->rt_multipath_alg); 2678 NLA_PUT_U32(skb, RTA_MP_ALGO, rt->rt_multipath_alg);
2678#endif 2679#endif
2679 if (rt->fl.iif) 2680 if (rt->fl.iif)
2680 NLA_PUT_U32(skb, RTA_PREFSRC, rt->rt_spec_dst); 2681 NLA_PUT_BE32(skb, RTA_PREFSRC, rt->rt_spec_dst);
2681 else if (rt->rt_src != rt->fl.fl4_src) 2682 else if (rt->rt_src != rt->fl.fl4_src)
2682 NLA_PUT_U32(skb, RTA_PREFSRC, rt->rt_src); 2683 NLA_PUT_BE32(skb, RTA_PREFSRC, rt->rt_src);
2683 2684
2684 if (rt->rt_dst != rt->rt_gateway) 2685 if (rt->rt_dst != rt->rt_gateway)
2685 NLA_PUT_U32(skb, RTA_GATEWAY, rt->rt_gateway); 2686 NLA_PUT_BE32(skb, RTA_GATEWAY, rt->rt_gateway);
2686 2687
2687 if (rtnetlink_put_metrics(skb, rt->u.dst.metrics) < 0) 2688 if (rtnetlink_put_metrics(skb, rt->u.dst.metrics) < 0)
2688 goto nla_put_failure; 2689 goto nla_put_failure;
@@ -2706,7 +2707,7 @@ static int rt_fill_info(struct sk_buff *skb, u32 pid, u32 seq, int event,
2706 2707
2707 if (rt->fl.iif) { 2708 if (rt->fl.iif) {
2708#ifdef CONFIG_IP_MROUTE 2709#ifdef CONFIG_IP_MROUTE
2709 u32 dst = rt->rt_dst; 2710 __be32 dst = rt->rt_dst;
2710 2711
2711 if (MULTICAST(dst) && !LOCAL_MCAST(dst) && 2712 if (MULTICAST(dst) && !LOCAL_MCAST(dst) &&
2712 ipv4_devconf.mc_forwarding) { 2713 ipv4_devconf.mc_forwarding) {
@@ -2740,7 +2741,9 @@ int inet_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr* nlh, void *arg)
2740 struct rtmsg *rtm; 2741 struct rtmsg *rtm;
2741 struct nlattr *tb[RTA_MAX+1]; 2742 struct nlattr *tb[RTA_MAX+1];
2742 struct rtable *rt = NULL; 2743 struct rtable *rt = NULL;
2743 u32 dst, src, iif; 2744 __be32 dst = 0;
2745 __be32 src = 0;
2746 u32 iif;
2744 int err; 2747 int err;
2745 struct sk_buff *skb; 2748 struct sk_buff *skb;
2746 2749
@@ -2765,8 +2768,8 @@ int inet_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr* nlh, void *arg)
2765 skb->nh.iph->protocol = IPPROTO_ICMP; 2768 skb->nh.iph->protocol = IPPROTO_ICMP;
2766 skb_reserve(skb, MAX_HEADER + sizeof(struct iphdr)); 2769 skb_reserve(skb, MAX_HEADER + sizeof(struct iphdr));
2767 2770
2768 src = tb[RTA_SRC] ? nla_get_u32(tb[RTA_SRC]) : 0; 2771 src = tb[RTA_SRC] ? nla_get_be32(tb[RTA_SRC]) : 0;
2769 dst = tb[RTA_DST] ? nla_get_u32(tb[RTA_DST]) : 0; 2772 dst = tb[RTA_DST] ? nla_get_be32(tb[RTA_DST]) : 0;
2770 iif = tb[RTA_IIF] ? nla_get_u32(tb[RTA_IIF]) : 0; 2773 iif = tb[RTA_IIF] ? nla_get_u32(tb[RTA_IIF]) : 0;
2771 2774
2772 if (iif) { 2775 if (iif) {
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index b3def0df14fb..3f884cea14ff 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -935,7 +935,7 @@ tcp_sacktag_write_queue(struct sock *sk, struct sk_buff *ack_skb, u32 prior_snd_
935 const struct inet_connection_sock *icsk = inet_csk(sk); 935 const struct inet_connection_sock *icsk = inet_csk(sk);
936 struct tcp_sock *tp = tcp_sk(sk); 936 struct tcp_sock *tp = tcp_sk(sk);
937 unsigned char *ptr = ack_skb->h.raw + TCP_SKB_CB(ack_skb)->sacked; 937 unsigned char *ptr = ack_skb->h.raw + TCP_SKB_CB(ack_skb)->sacked;
938 struct tcp_sack_block *sp = (struct tcp_sack_block *)(ptr+2); 938 struct tcp_sack_block_wire *sp = (struct tcp_sack_block_wire *)(ptr+2);
939 int num_sacks = (ptr[1] - TCPOLEN_SACK_BASE)>>3; 939 int num_sacks = (ptr[1] - TCPOLEN_SACK_BASE)>>3;
940 int reord = tp->packets_out; 940 int reord = tp->packets_out;
941 int prior_fackets; 941 int prior_fackets;
@@ -2239,13 +2239,12 @@ static int tcp_tso_acked(struct sock *sk, struct sk_buff *skb,
2239 return acked; 2239 return acked;
2240} 2240}
2241 2241
2242static u32 tcp_usrtt(const struct sk_buff *skb) 2242static u32 tcp_usrtt(struct timeval *tv)
2243{ 2243{
2244 struct timeval tv, now; 2244 struct timeval now;
2245 2245
2246 do_gettimeofday(&now); 2246 do_gettimeofday(&now);
2247 skb_get_timestamp(skb, &tv); 2247 return (now.tv_sec - tv->tv_sec) * 1000000 + (now.tv_usec - tv->tv_usec);
2248 return (now.tv_sec - tv.tv_sec) * 1000000 + (now.tv_usec - tv.tv_usec);
2249} 2248}
2250 2249
2251/* Remove acknowledged frames from the retransmission queue. */ 2250/* Remove acknowledged frames from the retransmission queue. */
@@ -2260,6 +2259,7 @@ static int tcp_clean_rtx_queue(struct sock *sk, __s32 *seq_rtt_p)
2260 u32 pkts_acked = 0; 2259 u32 pkts_acked = 0;
2261 void (*rtt_sample)(struct sock *sk, u32 usrtt) 2260 void (*rtt_sample)(struct sock *sk, u32 usrtt)
2262 = icsk->icsk_ca_ops->rtt_sample; 2261 = icsk->icsk_ca_ops->rtt_sample;
2262 struct timeval tv;
2263 2263
2264 while ((skb = skb_peek(&sk->sk_write_queue)) && 2264 while ((skb = skb_peek(&sk->sk_write_queue)) &&
2265 skb != sk->sk_send_head) { 2265 skb != sk->sk_send_head) {
@@ -2308,8 +2308,7 @@ static int tcp_clean_rtx_queue(struct sock *sk, __s32 *seq_rtt_p)
2308 seq_rtt = -1; 2308 seq_rtt = -1;
2309 } else if (seq_rtt < 0) { 2309 } else if (seq_rtt < 0) {
2310 seq_rtt = now - scb->when; 2310 seq_rtt = now - scb->when;
2311 if (rtt_sample) 2311 skb_get_timestamp(skb, &tv);
2312 (*rtt_sample)(sk, tcp_usrtt(skb));
2313 } 2312 }
2314 if (sacked & TCPCB_SACKED_ACKED) 2313 if (sacked & TCPCB_SACKED_ACKED)
2315 tp->sacked_out -= tcp_skb_pcount(skb); 2314 tp->sacked_out -= tcp_skb_pcount(skb);
@@ -2322,8 +2321,7 @@ static int tcp_clean_rtx_queue(struct sock *sk, __s32 *seq_rtt_p)
2322 } 2321 }
2323 } else if (seq_rtt < 0) { 2322 } else if (seq_rtt < 0) {
2324 seq_rtt = now - scb->when; 2323 seq_rtt = now - scb->when;
2325 if (rtt_sample) 2324 skb_get_timestamp(skb, &tv);
2326 (*rtt_sample)(sk, tcp_usrtt(skb));
2327 } 2325 }
2328 tcp_dec_pcount_approx(&tp->fackets_out, skb); 2326 tcp_dec_pcount_approx(&tp->fackets_out, skb);
2329 tcp_packets_out_dec(tp, skb); 2327 tcp_packets_out_dec(tp, skb);
@@ -2335,6 +2333,8 @@ static int tcp_clean_rtx_queue(struct sock *sk, __s32 *seq_rtt_p)
2335 if (acked&FLAG_ACKED) { 2333 if (acked&FLAG_ACKED) {
2336 tcp_ack_update_rtt(sk, acked, seq_rtt); 2334 tcp_ack_update_rtt(sk, acked, seq_rtt);
2337 tcp_ack_packets_out(sk, tp); 2335 tcp_ack_packets_out(sk, tp);
2336 if (rtt_sample && !(acked & FLAG_RETRANS_DATA_ACKED))
2337 (*rtt_sample)(sk, tcp_usrtt(&tv));
2338 2338
2339 if (icsk->icsk_ca_ops->pkts_acked) 2339 if (icsk->icsk_ca_ops->pkts_acked)
2340 icsk->icsk_ca_ops->pkts_acked(sk, pkts_acked); 2340 icsk->icsk_ca_ops->pkts_acked(sk, pkts_acked);
@@ -2629,7 +2629,7 @@ void tcp_parse_options(struct sk_buff *skb, struct tcp_options_received *opt_rx,
2629 switch(opcode) { 2629 switch(opcode) {
2630 case TCPOPT_MSS: 2630 case TCPOPT_MSS:
2631 if(opsize==TCPOLEN_MSS && th->syn && !estab) { 2631 if(opsize==TCPOLEN_MSS && th->syn && !estab) {
2632 u16 in_mss = ntohs(get_unaligned((__u16 *)ptr)); 2632 u16 in_mss = ntohs(get_unaligned((__be16 *)ptr));
2633 if (in_mss) { 2633 if (in_mss) {
2634 if (opt_rx->user_mss && opt_rx->user_mss < in_mss) 2634 if (opt_rx->user_mss && opt_rx->user_mss < in_mss)
2635 in_mss = opt_rx->user_mss; 2635 in_mss = opt_rx->user_mss;
@@ -2657,8 +2657,8 @@ void tcp_parse_options(struct sk_buff *skb, struct tcp_options_received *opt_rx,
2657 if ((estab && opt_rx->tstamp_ok) || 2657 if ((estab && opt_rx->tstamp_ok) ||
2658 (!estab && sysctl_tcp_timestamps)) { 2658 (!estab && sysctl_tcp_timestamps)) {
2659 opt_rx->saw_tstamp = 1; 2659 opt_rx->saw_tstamp = 1;
2660 opt_rx->rcv_tsval = ntohl(get_unaligned((__u32 *)ptr)); 2660 opt_rx->rcv_tsval = ntohl(get_unaligned((__be32 *)ptr));
2661 opt_rx->rcv_tsecr = ntohl(get_unaligned((__u32 *)(ptr+4))); 2661 opt_rx->rcv_tsecr = ntohl(get_unaligned((__be32 *)(ptr+4)));
2662 } 2662 }
2663 } 2663 }
2664 break; 2664 break;
@@ -2695,8 +2695,8 @@ static int tcp_fast_parse_options(struct sk_buff *skb, struct tcphdr *th,
2695 return 0; 2695 return 0;
2696 } else if (tp->rx_opt.tstamp_ok && 2696 } else if (tp->rx_opt.tstamp_ok &&
2697 th->doff == (sizeof(struct tcphdr)>>2)+(TCPOLEN_TSTAMP_ALIGNED>>2)) { 2697 th->doff == (sizeof(struct tcphdr)>>2)+(TCPOLEN_TSTAMP_ALIGNED>>2)) {
2698 __u32 *ptr = (__u32 *)(th + 1); 2698 __be32 *ptr = (__be32 *)(th + 1);
2699 if (*ptr == ntohl((TCPOPT_NOP << 24) | (TCPOPT_NOP << 16) 2699 if (*ptr == htonl((TCPOPT_NOP << 24) | (TCPOPT_NOP << 16)
2700 | (TCPOPT_TIMESTAMP << 8) | TCPOLEN_TIMESTAMP)) { 2700 | (TCPOPT_TIMESTAMP << 8) | TCPOLEN_TIMESTAMP)) {
2701 tp->rx_opt.saw_tstamp = 1; 2701 tp->rx_opt.saw_tstamp = 1;
2702 ++ptr; 2702 ++ptr;
@@ -3911,10 +3911,10 @@ int tcp_rcv_established(struct sock *sk, struct sk_buff *skb,
3911 3911
3912 /* Check timestamp */ 3912 /* Check timestamp */
3913 if (tcp_header_len == sizeof(struct tcphdr) + TCPOLEN_TSTAMP_ALIGNED) { 3913 if (tcp_header_len == sizeof(struct tcphdr) + TCPOLEN_TSTAMP_ALIGNED) {
3914 __u32 *ptr = (__u32 *)(th + 1); 3914 __be32 *ptr = (__be32 *)(th + 1);
3915 3915
3916 /* No? Slow path! */ 3916 /* No? Slow path! */
3917 if (*ptr != ntohl((TCPOPT_NOP << 24) | (TCPOPT_NOP << 16) 3917 if (*ptr != htonl((TCPOPT_NOP << 24) | (TCPOPT_NOP << 16)
3918 | (TCPOPT_TIMESTAMP << 8) | TCPOLEN_TIMESTAMP)) 3918 | (TCPOPT_TIMESTAMP << 8) | TCPOLEN_TIMESTAMP))
3919 goto slow_path; 3919 goto slow_path;
3920 3920
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index 39b179856082..c83938b8fcb1 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -159,7 +159,7 @@ int tcp_v4_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len)
159 struct tcp_sock *tp = tcp_sk(sk); 159 struct tcp_sock *tp = tcp_sk(sk);
160 struct sockaddr_in *usin = (struct sockaddr_in *)uaddr; 160 struct sockaddr_in *usin = (struct sockaddr_in *)uaddr;
161 struct rtable *rt; 161 struct rtable *rt;
162 u32 daddr, nexthop; 162 __be32 daddr, nexthop;
163 int tmp; 163 int tmp;
164 int err; 164 int err;
165 165
@@ -734,8 +734,8 @@ int tcp_v4_conn_request(struct sock *sk, struct sk_buff *skb)
734 struct inet_request_sock *ireq; 734 struct inet_request_sock *ireq;
735 struct tcp_options_received tmp_opt; 735 struct tcp_options_received tmp_opt;
736 struct request_sock *req; 736 struct request_sock *req;
737 __u32 saddr = skb->nh.iph->saddr; 737 __be32 saddr = skb->nh.iph->saddr;
738 __u32 daddr = skb->nh.iph->daddr; 738 __be32 daddr = skb->nh.iph->daddr;
739 __u32 isn = TCP_SKB_CB(skb)->when; 739 __u32 isn = TCP_SKB_CB(skb)->when;
740 struct dst_entry *dst = NULL; 740 struct dst_entry *dst = NULL;
741#ifdef CONFIG_SYN_COOKIES 741#ifdef CONFIG_SYN_COOKIES
@@ -1763,7 +1763,7 @@ static void get_tcp4_sock(struct sock *sp, char *tmpbuf, int i)
1763 1763
1764static void get_timewait4_sock(struct inet_timewait_sock *tw, char *tmpbuf, int i) 1764static void get_timewait4_sock(struct inet_timewait_sock *tw, char *tmpbuf, int i)
1765{ 1765{
1766 unsigned int dest, src; 1766 __be32 dest, src;
1767 __u16 destp, srcp; 1767 __u16 destp, srcp;
1768 int ttd = tw->tw_ttd - jiffies; 1768 int ttd = tw->tw_ttd - jiffies;
1769 1769
diff --git a/net/ipv4/tcp_lp.c b/net/ipv4/tcp_lp.c
index 308fb7e071c5..f0ebaf0e21cb 100644
--- a/net/ipv4/tcp_lp.c
+++ b/net/ipv4/tcp_lp.c
@@ -31,8 +31,6 @@
31 * Hung Hing Lun, Mike <hlhung3i@gmail.com> 31 * Hung Hing Lun, Mike <hlhung3i@gmail.com>
32 * SourceForge project page: 32 * SourceForge project page:
33 * http://tcp-lp-mod.sourceforge.net/ 33 * http://tcp-lp-mod.sourceforge.net/
34 *
35 * Version: $Id: tcp_lp.c,v 1.24 2006/09/05 20:22:53 hswong3i Exp $
36 */ 34 */
37 35
38#include <linux/module.h> 36#include <linux/module.h>
@@ -164,7 +162,7 @@ static u32 tcp_lp_remote_hz_estimator(struct sock *sk)
164 162
165 out: 163 out:
166 /* record time for successful remote HZ calc */ 164 /* record time for successful remote HZ calc */
167 if (rhz > 0) 165 if ((rhz >> 6) > 0)
168 lp->flag |= LP_VALID_RHZ; 166 lp->flag |= LP_VALID_RHZ;
169 else 167 else
170 lp->flag &= ~LP_VALID_RHZ; 168 lp->flag &= ~LP_VALID_RHZ;
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index 061edfae0c29..9a253faefc81 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -269,7 +269,7 @@ static u16 tcp_select_window(struct sock *sk)
269 return new_win; 269 return new_win;
270} 270}
271 271
272static void tcp_build_and_update_options(__u32 *ptr, struct tcp_sock *tp, 272static void tcp_build_and_update_options(__be32 *ptr, struct tcp_sock *tp,
273 __u32 tstamp) 273 __u32 tstamp)
274{ 274{
275 if (tp->rx_opt.tstamp_ok) { 275 if (tp->rx_opt.tstamp_ok) {
@@ -305,7 +305,7 @@ static void tcp_build_and_update_options(__u32 *ptr, struct tcp_sock *tp,
305 * MAX_SYN_SIZE to match the new maximum number of options that you 305 * MAX_SYN_SIZE to match the new maximum number of options that you
306 * can generate. 306 * can generate.
307 */ 307 */
308static void tcp_syn_build_options(__u32 *ptr, int mss, int ts, int sack, 308static void tcp_syn_build_options(__be32 *ptr, int mss, int ts, int sack,
309 int offer_wscale, int wscale, __u32 tstamp, 309 int offer_wscale, int wscale, __u32 tstamp,
310 __u32 ts_recent) 310 __u32 ts_recent)
311{ 311{
@@ -424,7 +424,7 @@ static int tcp_transmit_skb(struct sock *sk, struct sk_buff *skb, int clone_it,
424 th->dest = inet->dport; 424 th->dest = inet->dport;
425 th->seq = htonl(tcb->seq); 425 th->seq = htonl(tcb->seq);
426 th->ack_seq = htonl(tp->rcv_nxt); 426 th->ack_seq = htonl(tp->rcv_nxt);
427 *(((__u16 *)th) + 6) = htons(((tcp_header_size >> 2) << 12) | 427 *(((__be16 *)th) + 6) = htons(((tcp_header_size >> 2) << 12) |
428 tcb->flags); 428 tcb->flags);
429 429
430 if (unlikely(tcb->flags & TCPCB_FLAG_SYN)) { 430 if (unlikely(tcb->flags & TCPCB_FLAG_SYN)) {
@@ -445,7 +445,7 @@ static int tcp_transmit_skb(struct sock *sk, struct sk_buff *skb, int clone_it,
445 } 445 }
446 446
447 if (unlikely(tcb->flags & TCPCB_FLAG_SYN)) { 447 if (unlikely(tcb->flags & TCPCB_FLAG_SYN)) {
448 tcp_syn_build_options((__u32 *)(th + 1), 448 tcp_syn_build_options((__be32 *)(th + 1),
449 tcp_advertise_mss(sk), 449 tcp_advertise_mss(sk),
450 (sysctl_flags & SYSCTL_FLAG_TSTAMPS), 450 (sysctl_flags & SYSCTL_FLAG_TSTAMPS),
451 (sysctl_flags & SYSCTL_FLAG_SACK), 451 (sysctl_flags & SYSCTL_FLAG_SACK),
@@ -454,7 +454,7 @@ static int tcp_transmit_skb(struct sock *sk, struct sk_buff *skb, int clone_it,
454 tcb->when, 454 tcb->when,
455 tp->rx_opt.ts_recent); 455 tp->rx_opt.ts_recent);
456 } else { 456 } else {
457 tcp_build_and_update_options((__u32 *)(th + 1), 457 tcp_build_and_update_options((__be32 *)(th + 1),
458 tp, tcb->when); 458 tp, tcb->when);
459 TCP_ECN_send(sk, tp, skb, tcp_header_size); 459 TCP_ECN_send(sk, tp, skb, tcp_header_size);
460 } 460 }
@@ -2070,7 +2070,7 @@ struct sk_buff * tcp_make_synack(struct sock *sk, struct dst_entry *dst,
2070 th->window = htons(req->rcv_wnd); 2070 th->window = htons(req->rcv_wnd);
2071 2071
2072 TCP_SKB_CB(skb)->when = tcp_time_stamp; 2072 TCP_SKB_CB(skb)->when = tcp_time_stamp;
2073 tcp_syn_build_options((__u32 *)(th + 1), dst_metric(dst, RTAX_ADVMSS), ireq->tstamp_ok, 2073 tcp_syn_build_options((__be32 *)(th + 1), dst_metric(dst, RTAX_ADVMSS), ireq->tstamp_ok,
2074 ireq->sack_ok, ireq->wscale_ok, ireq->rcv_wscale, 2074 ireq->sack_ok, ireq->wscale_ok, ireq->rcv_wscale,
2075 TCP_SKB_CB(skb)->when, 2075 TCP_SKB_CB(skb)->when,
2076 req->ts_recent); 2076 req->ts_recent);
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index 77e265d7bb8f..6d6142f9c478 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -243,8 +243,8 @@ static void udp_v4_unhash(struct sock *sk)
243/* UDP is nearly always wildcards out the wazoo, it makes no sense to try 243/* UDP is nearly always wildcards out the wazoo, it makes no sense to try
244 * harder than this. -DaveM 244 * harder than this. -DaveM
245 */ 245 */
246static struct sock *udp_v4_lookup_longway(u32 saddr, u16 sport, 246static struct sock *udp_v4_lookup_longway(__be32 saddr, __be16 sport,
247 u32 daddr, u16 dport, int dif) 247 __be32 daddr, __be16 dport, int dif)
248{ 248{
249 struct sock *sk, *result = NULL; 249 struct sock *sk, *result = NULL;
250 struct hlist_node *node; 250 struct hlist_node *node;
@@ -288,8 +288,8 @@ static struct sock *udp_v4_lookup_longway(u32 saddr, u16 sport,
288 return result; 288 return result;
289} 289}
290 290
291static __inline__ struct sock *udp_v4_lookup(u32 saddr, u16 sport, 291static __inline__ struct sock *udp_v4_lookup(__be32 saddr, __be16 sport,
292 u32 daddr, u16 dport, int dif) 292 __be32 daddr, __be16 dport, int dif)
293{ 293{
294 struct sock *sk; 294 struct sock *sk;
295 295
@@ -302,8 +302,8 @@ static __inline__ struct sock *udp_v4_lookup(u32 saddr, u16 sport,
302} 302}
303 303
304static inline struct sock *udp_v4_mcast_next(struct sock *sk, 304static inline struct sock *udp_v4_mcast_next(struct sock *sk,
305 u16 loc_port, u32 loc_addr, 305 __be16 loc_port, __be32 loc_addr,
306 u16 rmt_port, u32 rmt_addr, 306 __be16 rmt_port, __be32 rmt_addr,
307 int dif) 307 int dif)
308{ 308{
309 struct hlist_node *node; 309 struct hlist_node *node;
@@ -498,7 +498,7 @@ out:
498} 498}
499 499
500 500
501static unsigned short udp_check(struct udphdr *uh, int len, unsigned long saddr, unsigned long daddr, unsigned long base) 501static unsigned short udp_check(struct udphdr *uh, int len, __be32 saddr, __be32 daddr, unsigned long base)
502{ 502{
503 return(csum_tcpudp_magic(saddr, daddr, len, IPPROTO_UDP, base)); 503 return(csum_tcpudp_magic(saddr, daddr, len, IPPROTO_UDP, base));
504} 504}
@@ -513,8 +513,8 @@ int udp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
513 struct rtable *rt = NULL; 513 struct rtable *rt = NULL;
514 int free = 0; 514 int free = 0;
515 int connected = 0; 515 int connected = 0;
516 u32 daddr, faddr, saddr; 516 __be32 daddr, faddr, saddr;
517 u16 dport; 517 __be16 dport;
518 u8 tos; 518 u8 tos;
519 int err; 519 int err;
520 int corkreq = up->corkflag || msg->msg_flags&MSG_MORE; 520 int corkreq = up->corkflag || msg->msg_flags&MSG_MORE;
@@ -931,7 +931,7 @@ static int udp_encap_rcv(struct sock * sk, struct sk_buff *skb)
931 int iphlen, len; 931 int iphlen, len;
932 932
933 __u8 *udpdata = (__u8 *)uh + sizeof(struct udphdr); 933 __u8 *udpdata = (__u8 *)uh + sizeof(struct udphdr);
934 __u32 *udpdata32 = (__u32 *)udpdata; 934 __be32 *udpdata32 = (__be32 *)udpdata;
935 __u16 encap_type = up->encap_type; 935 __u16 encap_type = up->encap_type;
936 936
937 /* if we're overly short, let UDP handle it */ 937 /* if we're overly short, let UDP handle it */
@@ -1080,7 +1080,7 @@ static int udp_queue_rcv_skb(struct sock * sk, struct sk_buff *skb)
1080 * so we don't need to lock the hashes. 1080 * so we don't need to lock the hashes.
1081 */ 1081 */
1082static int udp_v4_mcast_deliver(struct sk_buff *skb, struct udphdr *uh, 1082static int udp_v4_mcast_deliver(struct sk_buff *skb, struct udphdr *uh,
1083 u32 saddr, u32 daddr) 1083 __be32 saddr, __be32 daddr)
1084{ 1084{
1085 struct sock *sk; 1085 struct sock *sk;
1086 int dif; 1086 int dif;
@@ -1121,7 +1121,7 @@ static int udp_v4_mcast_deliver(struct sk_buff *skb, struct udphdr *uh,
1121 * including udp header and folding it to skb->csum. 1121 * including udp header and folding it to skb->csum.
1122 */ 1122 */
1123static void udp_checksum_init(struct sk_buff *skb, struct udphdr *uh, 1123static void udp_checksum_init(struct sk_buff *skb, struct udphdr *uh,
1124 unsigned short ulen, u32 saddr, u32 daddr) 1124 unsigned short ulen, __be32 saddr, __be32 daddr)
1125{ 1125{
1126 if (uh->check == 0) { 1126 if (uh->check == 0) {
1127 skb->ip_summed = CHECKSUM_UNNECESSARY; 1127 skb->ip_summed = CHECKSUM_UNNECESSARY;
@@ -1146,8 +1146,8 @@ int udp_rcv(struct sk_buff *skb)
1146 struct udphdr *uh; 1146 struct udphdr *uh;
1147 unsigned short ulen; 1147 unsigned short ulen;
1148 struct rtable *rt = (struct rtable*)skb->dst; 1148 struct rtable *rt = (struct rtable*)skb->dst;
1149 u32 saddr = skb->nh.iph->saddr; 1149 __be32 saddr = skb->nh.iph->saddr;
1150 u32 daddr = skb->nh.iph->daddr; 1150 __be32 daddr = skb->nh.iph->daddr;
1151 int len = skb->len; 1151 int len = skb->len;
1152 1152
1153 /* 1153 /*
@@ -1563,8 +1563,8 @@ void udp_proc_unregister(struct udp_seq_afinfo *afinfo)
1563static void udp4_format_sock(struct sock *sp, char *tmpbuf, int bucket) 1563static void udp4_format_sock(struct sock *sp, char *tmpbuf, int bucket)
1564{ 1564{
1565 struct inet_sock *inet = inet_sk(sp); 1565 struct inet_sock *inet = inet_sk(sp);
1566 unsigned int dest = inet->daddr; 1566 __be32 dest = inet->daddr;
1567 unsigned int src = inet->rcv_saddr; 1567 __be32 src = inet->rcv_saddr;
1568 __u16 destp = ntohs(inet->dport); 1568 __u16 destp = ntohs(inet->dport);
1569 __u16 srcp = ntohs(inet->sport); 1569 __u16 srcp = ntohs(inet->sport);
1570 1570
diff --git a/net/ipv4/xfrm4_input.c b/net/ipv4/xfrm4_input.c
index 040e8475f295..8655d038364c 100644
--- a/net/ipv4/xfrm4_input.c
+++ b/net/ipv4/xfrm4_input.c
@@ -23,7 +23,7 @@ int xfrm4_rcv(struct sk_buff *skb)
23 23
24EXPORT_SYMBOL(xfrm4_rcv); 24EXPORT_SYMBOL(xfrm4_rcv);
25 25
26static int xfrm4_parse_spi(struct sk_buff *skb, u8 nexthdr, u32 *spi, u32 *seq) 26static int xfrm4_parse_spi(struct sk_buff *skb, u8 nexthdr, __be32 *spi, __be32 *seq)
27{ 27{
28 switch (nexthdr) { 28 switch (nexthdr) {
29 case IPPROTO_IPIP: 29 case IPPROTO_IPIP:
@@ -55,7 +55,7 @@ drop:
55int xfrm4_rcv_encap(struct sk_buff *skb, __u16 encap_type) 55int xfrm4_rcv_encap(struct sk_buff *skb, __u16 encap_type)
56{ 56{
57 int err; 57 int err;
58 u32 spi, seq; 58 __be32 spi, seq;
59 struct xfrm_state *xfrm_vec[XFRM_MAX_DEPTH]; 59 struct xfrm_state *xfrm_vec[XFRM_MAX_DEPTH];
60 struct xfrm_state *x; 60 struct xfrm_state *x;
61 int xfrm_nr = 0; 61 int xfrm_nr = 0;
diff --git a/net/ipv4/xfrm4_policy.c b/net/ipv4/xfrm4_policy.c
index eabcd27b1767..7a7a00147e55 100644
--- a/net/ipv4/xfrm4_policy.c
+++ b/net/ipv4/xfrm4_policy.c
@@ -221,7 +221,7 @@ _decode_session4(struct sk_buff *skb, struct flowi *fl)
221 221
222 case IPPROTO_ESP: 222 case IPPROTO_ESP:
223 if (pskb_may_pull(skb, xprth + 4 - skb->data)) { 223 if (pskb_may_pull(skb, xprth + 4 - skb->data)) {
224 u32 *ehdr = (u32 *)xprth; 224 __be32 *ehdr = (__be32 *)xprth;
225 225
226 fl->fl_ipsec_spi = ehdr[0]; 226 fl->fl_ipsec_spi = ehdr[0];
227 } 227 }
@@ -229,7 +229,7 @@ _decode_session4(struct sk_buff *skb, struct flowi *fl)
229 229
230 case IPPROTO_AH: 230 case IPPROTO_AH:
231 if (pskb_may_pull(skb, xprth + 8 - skb->data)) { 231 if (pskb_may_pull(skb, xprth + 8 - skb->data)) {
232 u32 *ah_hdr = (u32*)xprth; 232 __be32 *ah_hdr = (__be32*)xprth;
233 233
234 fl->fl_ipsec_spi = ah_hdr[1]; 234 fl->fl_ipsec_spi = ah_hdr[1];
235 } 235 }
@@ -237,7 +237,7 @@ _decode_session4(struct sk_buff *skb, struct flowi *fl)
237 237
238 case IPPROTO_COMP: 238 case IPPROTO_COMP:
239 if (pskb_may_pull(skb, xprth + 4 - skb->data)) { 239 if (pskb_may_pull(skb, xprth + 4 - skb->data)) {
240 u16 *ipcomp_hdr = (u16 *)xprth; 240 __be16 *ipcomp_hdr = (__be16 *)xprth;
241 241
242 fl->fl_ipsec_spi = htonl(ntohs(ipcomp_hdr[1])); 242 fl->fl_ipsec_spi = htonl(ntohs(ipcomp_hdr[1]));
243 } 243 }
diff --git a/net/ipv4/xfrm4_state.c b/net/ipv4/xfrm4_state.c
index fe2034494d08..3cc3df0c6ece 100644
--- a/net/ipv4/xfrm4_state.c
+++ b/net/ipv4/xfrm4_state.c
@@ -29,9 +29,9 @@ __xfrm4_init_tempsel(struct xfrm_state *x, struct flowi *fl,
29 x->sel.daddr.a4 = fl->fl4_dst; 29 x->sel.daddr.a4 = fl->fl4_dst;
30 x->sel.saddr.a4 = fl->fl4_src; 30 x->sel.saddr.a4 = fl->fl4_src;
31 x->sel.dport = xfrm_flowi_dport(fl); 31 x->sel.dport = xfrm_flowi_dport(fl);
32 x->sel.dport_mask = ~0; 32 x->sel.dport_mask = htons(0xffff);
33 x->sel.sport = xfrm_flowi_sport(fl); 33 x->sel.sport = xfrm_flowi_sport(fl);
34 x->sel.sport_mask = ~0; 34 x->sel.sport_mask = htons(0xffff);
35 x->sel.prefixlen_d = 32; 35 x->sel.prefixlen_d = 32;
36 x->sel.prefixlen_s = 32; 36 x->sel.prefixlen_s = 32;
37 x->sel.proto = fl->proto; 37 x->sel.proto = fl->proto;
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index c18676352397..e03c33b2465b 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -1258,8 +1258,8 @@ int ipv6_rcv_saddr_equal(const struct sock *sk, const struct sock *sk2)
1258{ 1258{
1259 const struct in6_addr *sk_rcv_saddr6 = &inet6_sk(sk)->rcv_saddr; 1259 const struct in6_addr *sk_rcv_saddr6 = &inet6_sk(sk)->rcv_saddr;
1260 const struct in6_addr *sk2_rcv_saddr6 = inet6_rcv_saddr(sk2); 1260 const struct in6_addr *sk2_rcv_saddr6 = inet6_rcv_saddr(sk2);
1261 u32 sk_rcv_saddr = inet_sk(sk)->rcv_saddr; 1261 __be32 sk_rcv_saddr = inet_sk(sk)->rcv_saddr;
1262 u32 sk2_rcv_saddr = inet_rcv_saddr(sk2); 1262 __be32 sk2_rcv_saddr = inet_rcv_saddr(sk2);
1263 int sk_ipv6only = ipv6_only_sock(sk); 1263 int sk_ipv6only = ipv6_only_sock(sk);
1264 int sk2_ipv6only = inet_v6_ipv6only(sk2); 1264 int sk2_ipv6only = inet_v6_ipv6only(sk2);
1265 int addr_type = ipv6_addr_type(sk_rcv_saddr6); 1265 int addr_type = ipv6_addr_type(sk_rcv_saddr6);
diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c
index bf6e8aff19d4..e94eccb99707 100644
--- a/net/ipv6/af_inet6.c
+++ b/net/ipv6/af_inet6.c
@@ -246,7 +246,7 @@ int inet6_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
246 struct sock *sk = sock->sk; 246 struct sock *sk = sock->sk;
247 struct inet_sock *inet = inet_sk(sk); 247 struct inet_sock *inet = inet_sk(sk);
248 struct ipv6_pinfo *np = inet6_sk(sk); 248 struct ipv6_pinfo *np = inet6_sk(sk);
249 __u32 v4addr = 0; 249 __be32 v4addr = 0;
250 unsigned short snum; 250 unsigned short snum;
251 int addr_type = 0; 251 int addr_type = 0;
252 int err = 0; 252 int err = 0;
diff --git a/net/ipv6/inet6_hashtables.c b/net/ipv6/inet6_hashtables.c
index d2f3fc990bfa..8accd1fbeeda 100644
--- a/net/ipv6/inet6_hashtables.c
+++ b/net/ipv6/inet6_hashtables.c
@@ -64,7 +64,7 @@ struct sock *__inet6_lookup_established(struct inet_hashinfo *hashinfo,
64{ 64{
65 struct sock *sk; 65 struct sock *sk;
66 const struct hlist_node *node; 66 const struct hlist_node *node;
67 const __u32 ports = INET_COMBINED_PORTS(sport, hnum); 67 const __portpair ports = INET_COMBINED_PORTS(sport, hnum);
68 /* Optimize here for direct hit, only listening connections can 68 /* Optimize here for direct hit, only listening connections can
69 * have wildcards anyways. 69 * have wildcards anyways.
70 */ 70 */
@@ -82,7 +82,7 @@ struct sock *__inet6_lookup_established(struct inet_hashinfo *hashinfo,
82 sk_for_each(sk, node, &(head + hashinfo->ehash_size)->chain) { 82 sk_for_each(sk, node, &(head + hashinfo->ehash_size)->chain) {
83 const struct inet_timewait_sock *tw = inet_twsk(sk); 83 const struct inet_timewait_sock *tw = inet_twsk(sk);
84 84
85 if(*((__u32 *)&(tw->tw_dport)) == ports && 85 if(*((__portpair *)&(tw->tw_dport)) == ports &&
86 sk->sk_family == PF_INET6) { 86 sk->sk_family == PF_INET6) {
87 const struct inet6_timewait_sock *tw6 = inet6_twsk(sk); 87 const struct inet6_timewait_sock *tw6 = inet6_twsk(sk);
88 88
@@ -171,7 +171,7 @@ static int __inet6_check_established(struct inet_timewait_death_row *death_row,
171 const struct in6_addr *daddr = &np->rcv_saddr; 171 const struct in6_addr *daddr = &np->rcv_saddr;
172 const struct in6_addr *saddr = &np->daddr; 172 const struct in6_addr *saddr = &np->daddr;
173 const int dif = sk->sk_bound_dev_if; 173 const int dif = sk->sk_bound_dev_if;
174 const u32 ports = INET_COMBINED_PORTS(inet->dport, lport); 174 const __portpair ports = INET_COMBINED_PORTS(inet->dport, lport);
175 const unsigned int hash = inet6_ehashfn(daddr, inet->num, saddr, 175 const unsigned int hash = inet6_ehashfn(daddr, inet->num, saddr,
176 inet->dport); 176 inet->dport);
177 struct inet_ehash_bucket *head = inet_ehash_bucket(hinfo, hash); 177 struct inet_ehash_bucket *head = inet_ehash_bucket(hinfo, hash);
@@ -188,7 +188,7 @@ static int __inet6_check_established(struct inet_timewait_death_row *death_row,
188 188
189 tw = inet_twsk(sk2); 189 tw = inet_twsk(sk2);
190 190
191 if(*((__u32 *)&(tw->tw_dport)) == ports && 191 if(*((__portpair *)&(tw->tw_dport)) == ports &&
192 sk2->sk_family == PF_INET6 && 192 sk2->sk_family == PF_INET6 &&
193 ipv6_addr_equal(&tw6->tw_v6_daddr, saddr) && 193 ipv6_addr_equal(&tw6->tw_v6_daddr, saddr) &&
194 ipv6_addr_equal(&tw6->tw_v6_rcv_saddr, daddr) && 194 ipv6_addr_equal(&tw6->tw_v6_rcv_saddr, daddr) &&
diff --git a/net/ipv6/ipcomp6.c b/net/ipv6/ipcomp6.c
index ad9c6e824e62..a2860e35efd7 100644
--- a/net/ipv6/ipcomp6.c
+++ b/net/ipv6/ipcomp6.c
@@ -178,7 +178,7 @@ out_ok:
178static void ipcomp6_err(struct sk_buff *skb, struct inet6_skb_parm *opt, 178static void ipcomp6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
179 int type, int code, int offset, __u32 info) 179 int type, int code, int offset, __u32 info)
180{ 180{
181 u32 spi; 181 __be32 spi;
182 struct ipv6hdr *iph = (struct ipv6hdr*)skb->data; 182 struct ipv6hdr *iph = (struct ipv6hdr*)skb->data;
183 struct ipv6_comp_hdr *ipcomph = (struct ipv6_comp_hdr*)(skb->data+offset); 183 struct ipv6_comp_hdr *ipcomph = (struct ipv6_comp_hdr*)(skb->data+offset);
184 struct xfrm_state *x; 184 struct xfrm_state *x;
@@ -234,7 +234,7 @@ static int ipcomp6_tunnel_attach(struct xfrm_state *x)
234{ 234{
235 int err = 0; 235 int err = 0;
236 struct xfrm_state *t = NULL; 236 struct xfrm_state *t = NULL;
237 u32 spi; 237 __be32 spi;
238 238
239 spi = xfrm6_tunnel_spi_lookup((xfrm_address_t *)&x->props.saddr); 239 spi = xfrm6_tunnel_spi_lookup((xfrm_address_t *)&x->props.saddr);
240 if (spi) 240 if (spi)
diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
index 4f3bb7fcc8b5..de6b91981b30 100644
--- a/net/ipv6/ipv6_sockglue.c
+++ b/net/ipv6/ipv6_sockglue.c
@@ -123,6 +123,9 @@ static struct sk_buff *ipv6_gso_segment(struct sk_buff *skb, int features)
123 struct ipv6hdr *ipv6h; 123 struct ipv6hdr *ipv6h;
124 struct inet6_protocol *ops; 124 struct inet6_protocol *ops;
125 125
126 if (!(features & NETIF_F_HW_CSUM))
127 features &= ~NETIF_F_SG;
128
126 if (unlikely(skb_shinfo(skb)->gso_type & 129 if (unlikely(skb_shinfo(skb)->gso_type &
127 ~(SKB_GSO_UDP | 130 ~(SKB_GSO_UDP |
128 SKB_GSO_DODGY | 131 SKB_GSO_DODGY |
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index 2546fc9f0a78..3b6575478fcc 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -1237,7 +1237,7 @@ process:
1237 1237
1238 skb->dev = NULL; 1238 skb->dev = NULL;
1239 1239
1240 bh_lock_sock(sk); 1240 bh_lock_sock_nested(sk);
1241 ret = 0; 1241 ret = 0;
1242 if (!sock_owned_by_user(sk)) { 1242 if (!sock_owned_by_user(sk)) {
1243#ifdef CONFIG_NET_DMA 1243#ifdef CONFIG_NET_DMA
diff --git a/net/ipv6/xfrm6_input.c b/net/ipv6/xfrm6_input.c
index a40a05789013..5c8b7a568800 100644
--- a/net/ipv6/xfrm6_input.c
+++ b/net/ipv6/xfrm6_input.c
@@ -16,10 +16,10 @@
16#include <net/ipv6.h> 16#include <net/ipv6.h>
17#include <net/xfrm.h> 17#include <net/xfrm.h>
18 18
19int xfrm6_rcv_spi(struct sk_buff *skb, u32 spi) 19int xfrm6_rcv_spi(struct sk_buff *skb, __be32 spi)
20{ 20{
21 int err; 21 int err;
22 u32 seq; 22 __be32 seq;
23 struct xfrm_state *xfrm_vec[XFRM_MAX_DEPTH]; 23 struct xfrm_state *xfrm_vec[XFRM_MAX_DEPTH];
24 struct xfrm_state *x; 24 struct xfrm_state *x;
25 int xfrm_nr = 0; 25 int xfrm_nr = 0;
diff --git a/net/ipv6/xfrm6_state.c b/net/ipv6/xfrm6_state.c
index 711bfafb2472..9ddaa9d41539 100644
--- a/net/ipv6/xfrm6_state.c
+++ b/net/ipv6/xfrm6_state.c
@@ -29,9 +29,9 @@ __xfrm6_init_tempsel(struct xfrm_state *x, struct flowi *fl,
29 ipv6_addr_copy((struct in6_addr *)&x->sel.daddr, &fl->fl6_dst); 29 ipv6_addr_copy((struct in6_addr *)&x->sel.daddr, &fl->fl6_dst);
30 ipv6_addr_copy((struct in6_addr *)&x->sel.saddr, &fl->fl6_src); 30 ipv6_addr_copy((struct in6_addr *)&x->sel.saddr, &fl->fl6_src);
31 x->sel.dport = xfrm_flowi_dport(fl); 31 x->sel.dport = xfrm_flowi_dport(fl);
32 x->sel.dport_mask = ~0; 32 x->sel.dport_mask = htons(0xffff);
33 x->sel.sport = xfrm_flowi_sport(fl); 33 x->sel.sport = xfrm_flowi_sport(fl);
34 x->sel.sport_mask = ~0; 34 x->sel.sport_mask = htons(0xffff);
35 x->sel.prefixlen_d = 128; 35 x->sel.prefixlen_d = 128;
36 x->sel.prefixlen_s = 128; 36 x->sel.prefixlen_s = 128;
37 x->sel.proto = fl->proto; 37 x->sel.proto = fl->proto;
diff --git a/net/ipv6/xfrm6_tunnel.c b/net/ipv6/xfrm6_tunnel.c
index 59685ee8f700..7af227bb1551 100644
--- a/net/ipv6/xfrm6_tunnel.c
+++ b/net/ipv6/xfrm6_tunnel.c
@@ -258,7 +258,7 @@ static int xfrm6_tunnel_input(struct xfrm_state *x, struct sk_buff *skb)
258static int xfrm6_tunnel_rcv(struct sk_buff *skb) 258static int xfrm6_tunnel_rcv(struct sk_buff *skb)
259{ 259{
260 struct ipv6hdr *iph = skb->nh.ipv6h; 260 struct ipv6hdr *iph = skb->nh.ipv6h;
261 u32 spi; 261 __be32 spi;
262 262
263 spi = xfrm6_tunnel_spi_lookup((xfrm_address_t *)&iph->saddr); 263 spi = xfrm6_tunnel_spi_lookup((xfrm_address_t *)&iph->saddr);
264 return xfrm6_rcv_spi(skb, spi); 264 return xfrm6_rcv_spi(skb, spi);
diff --git a/net/irda/af_irda.c b/net/irda/af_irda.c
index 17699eeb64d7..7e1aea89ef05 100644
--- a/net/irda/af_irda.c
+++ b/net/irda/af_irda.c
@@ -132,13 +132,14 @@ static void irda_disconnect_indication(void *instance, void *sap,
132 132
133 /* Prevent race conditions with irda_release() and irda_shutdown() */ 133 /* Prevent race conditions with irda_release() and irda_shutdown() */
134 if (!sock_flag(sk, SOCK_DEAD) && sk->sk_state != TCP_CLOSE) { 134 if (!sock_flag(sk, SOCK_DEAD) && sk->sk_state != TCP_CLOSE) {
135 lock_sock(sk);
135 sk->sk_state = TCP_CLOSE; 136 sk->sk_state = TCP_CLOSE;
136 sk->sk_err = ECONNRESET; 137 sk->sk_err = ECONNRESET;
137 sk->sk_shutdown |= SEND_SHUTDOWN; 138 sk->sk_shutdown |= SEND_SHUTDOWN;
138 139
139 sk->sk_state_change(sk); 140 sk->sk_state_change(sk);
140 /* Uh-oh... Should use sock_orphan ? */ 141 sock_orphan(sk);
141 sock_set_flag(sk, SOCK_DEAD); 142 release_sock(sk);
142 143
143 /* Close our TSAP. 144 /* Close our TSAP.
144 * If we leave it open, IrLMP put it back into the list of 145 * If we leave it open, IrLMP put it back into the list of
@@ -308,7 +309,8 @@ static void irda_connect_response(struct irda_sock *self)
308 309
309 IRDA_ASSERT(self != NULL, return;); 310 IRDA_ASSERT(self != NULL, return;);
310 311
311 skb = alloc_skb(64, GFP_ATOMIC); 312 skb = alloc_skb(TTP_MAX_HEADER + TTP_SAR_HEADER,
313 GFP_ATOMIC);
312 if (skb == NULL) { 314 if (skb == NULL) {
313 IRDA_DEBUG(0, "%s() Unable to allocate sk_buff!\n", 315 IRDA_DEBUG(0, "%s() Unable to allocate sk_buff!\n",
314 __FUNCTION__); 316 __FUNCTION__);
@@ -1212,6 +1214,7 @@ static int irda_release(struct socket *sock)
1212 if (sk == NULL) 1214 if (sk == NULL)
1213 return 0; 1215 return 0;
1214 1216
1217 lock_sock(sk);
1215 sk->sk_state = TCP_CLOSE; 1218 sk->sk_state = TCP_CLOSE;
1216 sk->sk_shutdown |= SEND_SHUTDOWN; 1219 sk->sk_shutdown |= SEND_SHUTDOWN;
1217 sk->sk_state_change(sk); 1220 sk->sk_state_change(sk);
@@ -1221,6 +1224,7 @@ static int irda_release(struct socket *sock)
1221 1224
1222 sock_orphan(sk); 1225 sock_orphan(sk);
1223 sock->sk = NULL; 1226 sock->sk = NULL;
1227 release_sock(sk);
1224 1228
1225 /* Purge queues (see sock_init_data()) */ 1229 /* Purge queues (see sock_init_data()) */
1226 skb_queue_purge(&sk->sk_receive_queue); 1230 skb_queue_purge(&sk->sk_receive_queue);
@@ -1353,6 +1357,7 @@ static int irda_recvmsg_dgram(struct kiocb *iocb, struct socket *sock,
1353 IRDA_DEBUG(4, "%s()\n", __FUNCTION__); 1357 IRDA_DEBUG(4, "%s()\n", __FUNCTION__);
1354 1358
1355 IRDA_ASSERT(self != NULL, return -1;); 1359 IRDA_ASSERT(self != NULL, return -1;);
1360 IRDA_ASSERT(!sock_error(sk), return -1;);
1356 1361
1357 skb = skb_recv_datagram(sk, flags & ~MSG_DONTWAIT, 1362 skb = skb_recv_datagram(sk, flags & ~MSG_DONTWAIT,
1358 flags & MSG_DONTWAIT, &err); 1363 flags & MSG_DONTWAIT, &err);
@@ -1405,6 +1410,7 @@ static int irda_recvmsg_stream(struct kiocb *iocb, struct socket *sock,
1405 IRDA_DEBUG(3, "%s()\n", __FUNCTION__); 1410 IRDA_DEBUG(3, "%s()\n", __FUNCTION__);
1406 1411
1407 IRDA_ASSERT(self != NULL, return -1;); 1412 IRDA_ASSERT(self != NULL, return -1;);
1413 IRDA_ASSERT(!sock_error(sk), return -1;);
1408 1414
1409 if (sock->flags & __SO_ACCEPTCON) 1415 if (sock->flags & __SO_ACCEPTCON)
1410 return(-EINVAL); 1416 return(-EINVAL);
diff --git a/net/irda/ircomm/ircomm_lmp.c b/net/irda/ircomm/ircomm_lmp.c
index 959874b6451f..c8e0d89ee11f 100644
--- a/net/irda/ircomm/ircomm_lmp.c
+++ b/net/irda/ircomm/ircomm_lmp.c
@@ -81,7 +81,7 @@ static int ircomm_lmp_connect_response(struct ircomm_cb *self,
81 81
82 /* Any userdata supplied? */ 82 /* Any userdata supplied? */
83 if (userdata == NULL) { 83 if (userdata == NULL) {
84 tx_skb = alloc_skb(64, GFP_ATOMIC); 84 tx_skb = alloc_skb(LMP_MAX_HEADER, GFP_ATOMIC);
85 if (!tx_skb) 85 if (!tx_skb)
86 return -ENOMEM; 86 return -ENOMEM;
87 87
@@ -115,7 +115,7 @@ static int ircomm_lmp_disconnect_request(struct ircomm_cb *self,
115 IRDA_DEBUG(0, "%s()\n", __FUNCTION__ ); 115 IRDA_DEBUG(0, "%s()\n", __FUNCTION__ );
116 116
117 if (!userdata) { 117 if (!userdata) {
118 tx_skb = alloc_skb(64, GFP_ATOMIC); 118 tx_skb = alloc_skb(LMP_MAX_HEADER, GFP_ATOMIC);
119 if (!tx_skb) 119 if (!tx_skb)
120 return -ENOMEM; 120 return -ENOMEM;
121 121
diff --git a/net/irda/iriap.c b/net/irda/iriap.c
index 61128aa05b40..415cf4eec23b 100644
--- a/net/irda/iriap.c
+++ b/net/irda/iriap.c
@@ -345,10 +345,11 @@ static void iriap_disconnect_request(struct iriap_cb *self)
345 IRDA_ASSERT(self != NULL, return;); 345 IRDA_ASSERT(self != NULL, return;);
346 IRDA_ASSERT(self->magic == IAS_MAGIC, return;); 346 IRDA_ASSERT(self->magic == IAS_MAGIC, return;);
347 347
348 tx_skb = alloc_skb(64, GFP_ATOMIC); 348 tx_skb = alloc_skb(LMP_MAX_HEADER, GFP_ATOMIC);
349 if (tx_skb == NULL) { 349 if (tx_skb == NULL) {
350 IRDA_DEBUG(0, "%s(), Could not allocate an sk_buff of length %d\n", 350 IRDA_DEBUG(0,
351 __FUNCTION__, 64); 351 "%s(), Could not allocate an sk_buff of length %d\n",
352 __FUNCTION__, LMP_MAX_HEADER);
352 return; 353 return;
353 } 354 }
354 355
@@ -701,7 +702,7 @@ void iriap_send_ack(struct iriap_cb *self)
701 IRDA_ASSERT(self != NULL, return;); 702 IRDA_ASSERT(self != NULL, return;);
702 IRDA_ASSERT(self->magic == IAS_MAGIC, return;); 703 IRDA_ASSERT(self->magic == IAS_MAGIC, return;);
703 704
704 tx_skb = alloc_skb(64, GFP_ATOMIC); 705 tx_skb = alloc_skb(LMP_MAX_HEADER + 1, GFP_ATOMIC);
705 if (!tx_skb) 706 if (!tx_skb)
706 return; 707 return;
707 708
diff --git a/net/irda/iriap_event.c b/net/irda/iriap_event.c
index da17395df05a..99b18dc7a0b7 100644
--- a/net/irda/iriap_event.c
+++ b/net/irda/iriap_event.c
@@ -365,7 +365,7 @@ static void state_r_disconnect(struct iriap_cb *self, IRIAP_EVENT event,
365 365
366 switch (event) { 366 switch (event) {
367 case IAP_LM_CONNECT_INDICATION: 367 case IAP_LM_CONNECT_INDICATION:
368 tx_skb = alloc_skb(64, GFP_ATOMIC); 368 tx_skb = alloc_skb(LMP_MAX_HEADER, GFP_ATOMIC);
369 if (tx_skb == NULL) { 369 if (tx_skb == NULL) {
370 IRDA_WARNING("%s: unable to malloc!\n", __FUNCTION__); 370 IRDA_WARNING("%s: unable to malloc!\n", __FUNCTION__);
371 return; 371 return;
diff --git a/net/irda/irlan/irlan_common.c b/net/irda/irlan/irlan_common.c
index 7dd0a2fe1d20..9b962f247714 100644
--- a/net/irda/irlan/irlan_common.c
+++ b/net/irda/irlan/irlan_common.c
@@ -636,7 +636,8 @@ void irlan_get_provider_info(struct irlan_cb *self)
636 IRDA_ASSERT(self != NULL, return;); 636 IRDA_ASSERT(self != NULL, return;);
637 IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;); 637 IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;);
638 638
639 skb = alloc_skb(64, GFP_ATOMIC); 639 skb = alloc_skb(IRLAN_MAX_HEADER + IRLAN_CMD_HEADER,
640 GFP_ATOMIC);
640 if (!skb) 641 if (!skb)
641 return; 642 return;
642 643
@@ -668,7 +669,10 @@ void irlan_open_data_channel(struct irlan_cb *self)
668 IRDA_ASSERT(self != NULL, return;); 669 IRDA_ASSERT(self != NULL, return;);
669 IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;); 670 IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;);
670 671
671 skb = alloc_skb(64, GFP_ATOMIC); 672 skb = alloc_skb(IRLAN_MAX_HEADER + IRLAN_CMD_HEADER +
673 IRLAN_STRING_PARAMETER_LEN("MEDIA", "802.3") +
674 IRLAN_STRING_PARAMETER_LEN("ACCESS_TYPE", "DIRECT"),
675 GFP_ATOMIC);
672 if (!skb) 676 if (!skb)
673 return; 677 return;
674 678
@@ -704,7 +708,9 @@ void irlan_close_data_channel(struct irlan_cb *self)
704 if (self->client.tsap_ctrl == NULL) 708 if (self->client.tsap_ctrl == NULL)
705 return; 709 return;
706 710
707 skb = alloc_skb(64, GFP_ATOMIC); 711 skb = alloc_skb(IRLAN_MAX_HEADER + IRLAN_CMD_HEADER +
712 IRLAN_BYTE_PARAMETER_LEN("DATA_CHAN"),
713 GFP_ATOMIC);
708 if (!skb) 714 if (!skb)
709 return; 715 return;
710 716
@@ -715,7 +721,7 @@ void irlan_close_data_channel(struct irlan_cb *self)
715 721
716 /* Build frame */ 722 /* Build frame */
717 frame[0] = CMD_CLOSE_DATA_CHAN; 723 frame[0] = CMD_CLOSE_DATA_CHAN;
718 frame[1] = 0x01; /* Two parameters */ 724 frame[1] = 0x01; /* One parameter */
719 725
720 irlan_insert_byte_param(skb, "DATA_CHAN", self->dtsap_sel_data); 726 irlan_insert_byte_param(skb, "DATA_CHAN", self->dtsap_sel_data);
721 727
@@ -739,7 +745,11 @@ static void irlan_open_unicast_addr(struct irlan_cb *self)
739 IRDA_ASSERT(self != NULL, return;); 745 IRDA_ASSERT(self != NULL, return;);
740 IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;); 746 IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;);
741 747
742 skb = alloc_skb(128, GFP_ATOMIC); 748 skb = alloc_skb(IRLAN_MAX_HEADER + IRLAN_CMD_HEADER +
749 IRLAN_BYTE_PARAMETER_LEN("DATA_CHAN") +
750 IRLAN_STRING_PARAMETER_LEN("FILTER_TYPE", "DIRECTED") +
751 IRLAN_STRING_PARAMETER_LEN("FILTER_MODE", "FILTER"),
752 GFP_ATOMIC);
743 if (!skb) 753 if (!skb)
744 return; 754 return;
745 755
@@ -777,7 +787,12 @@ void irlan_set_broadcast_filter(struct irlan_cb *self, int status)
777 IRDA_ASSERT(self != NULL, return;); 787 IRDA_ASSERT(self != NULL, return;);
778 IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;); 788 IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;);
779 789
780 skb = alloc_skb(128, GFP_ATOMIC); 790 skb = alloc_skb(IRLAN_MAX_HEADER + IRLAN_CMD_HEADER +
791 IRLAN_BYTE_PARAMETER_LEN("DATA_CHAN") +
792 IRLAN_STRING_PARAMETER_LEN("FILTER_TYPE", "BROADCAST") +
793 /* We may waste one byte here...*/
794 IRLAN_STRING_PARAMETER_LEN("FILTER_MODE", "FILTER"),
795 GFP_ATOMIC);
781 if (!skb) 796 if (!skb)
782 return; 797 return;
783 798
@@ -816,7 +831,12 @@ void irlan_set_multicast_filter(struct irlan_cb *self, int status)
816 IRDA_ASSERT(self != NULL, return;); 831 IRDA_ASSERT(self != NULL, return;);
817 IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;); 832 IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;);
818 833
819 skb = alloc_skb(128, GFP_ATOMIC); 834 skb = alloc_skb(IRLAN_MAX_HEADER + IRLAN_CMD_HEADER +
835 IRLAN_BYTE_PARAMETER_LEN("DATA_CHAN") +
836 IRLAN_STRING_PARAMETER_LEN("FILTER_TYPE", "MULTICAST") +
837 /* We may waste one byte here...*/
838 IRLAN_STRING_PARAMETER_LEN("FILTER_MODE", "NONE"),
839 GFP_ATOMIC);
820 if (!skb) 840 if (!skb)
821 return; 841 return;
822 842
@@ -856,7 +876,12 @@ static void irlan_get_unicast_addr(struct irlan_cb *self)
856 IRDA_ASSERT(self != NULL, return;); 876 IRDA_ASSERT(self != NULL, return;);
857 IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;); 877 IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;);
858 878
859 skb = alloc_skb(128, GFP_ATOMIC); 879 skb = alloc_skb(IRLAN_MAX_HEADER + IRLAN_CMD_HEADER +
880 IRLAN_BYTE_PARAMETER_LEN("DATA_CHAN") +
881 IRLAN_STRING_PARAMETER_LEN("FILTER_TYPE", "DIRECTED") +
882 IRLAN_STRING_PARAMETER_LEN("FILTER_OPERATION",
883 "DYNAMIC"),
884 GFP_ATOMIC);
860 if (!skb) 885 if (!skb)
861 return; 886 return;
862 887
@@ -891,7 +916,10 @@ void irlan_get_media_char(struct irlan_cb *self)
891 IRDA_ASSERT(self != NULL, return;); 916 IRDA_ASSERT(self != NULL, return;);
892 IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;); 917 IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;);
893 918
894 skb = alloc_skb(64, GFP_ATOMIC); 919 skb = alloc_skb(IRLAN_MAX_HEADER + IRLAN_CMD_HEADER +
920 IRLAN_STRING_PARAMETER_LEN("MEDIA", "802.3"),
921 GFP_ATOMIC);
922
895 if (!skb) 923 if (!skb)
896 return; 924 return;
897 925
diff --git a/net/irda/irlan/irlan_provider.c b/net/irda/irlan/irlan_provider.c
index 9c0df86044d7..58efde919667 100644
--- a/net/irda/irlan/irlan_provider.c
+++ b/net/irda/irlan/irlan_provider.c
@@ -296,7 +296,14 @@ void irlan_provider_send_reply(struct irlan_cb *self, int command,
296 IRDA_ASSERT(self != NULL, return;); 296 IRDA_ASSERT(self != NULL, return;);
297 IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;); 297 IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;);
298 298
299 skb = alloc_skb(128, GFP_ATOMIC); 299 skb = alloc_skb(IRLAN_MAX_HEADER + IRLAN_CMD_HEADER +
300 /* Bigger param length comes from CMD_GET_MEDIA_CHAR */
301 IRLAN_STRING_PARAMETER_LEN("FILTER_TYPE", "DIRECTED") +
302 IRLAN_STRING_PARAMETER_LEN("FILTER_TYPE", "BORADCAST") +
303 IRLAN_STRING_PARAMETER_LEN("FILTER_TYPE", "MULTICAST") +
304 IRLAN_STRING_PARAMETER_LEN("ACCESS_TYPE", "HOSTED"),
305 GFP_ATOMIC);
306
300 if (!skb) 307 if (!skb)
301 return; 308 return;
302 309
@@ -354,8 +361,7 @@ void irlan_provider_send_reply(struct irlan_cb *self, int command,
354 } else 361 } else
355 skb->data[1] = 0x02; /* 2 parameters */ 362 skb->data[1] = 0x02; /* 2 parameters */
356 irlan_insert_byte_param(skb, "DATA_CHAN", self->stsap_sel_data); 363 irlan_insert_byte_param(skb, "DATA_CHAN", self->stsap_sel_data);
357 irlan_insert_array_param(skb, "RECONNECT_KEY", "LINUX RULES!", 364 irlan_insert_string_param(skb, "RECONNECT_KEY", "LINUX RULES!");
358 12);
359 break; 365 break;
360 case CMD_FILTER_OPERATION: 366 case CMD_FILTER_OPERATION:
361 irlan_filter_request(self, skb); 367 irlan_filter_request(self, skb);
diff --git a/net/irda/irlap_frame.c b/net/irda/irlap_frame.c
index ccb983bf0f4a..dba349c832d0 100644
--- a/net/irda/irlap_frame.c
+++ b/net/irda/irlap_frame.c
@@ -117,7 +117,9 @@ void irlap_send_snrm_frame(struct irlap_cb *self, struct qos_info *qos)
117 IRDA_ASSERT(self->magic == LAP_MAGIC, return;); 117 IRDA_ASSERT(self->magic == LAP_MAGIC, return;);
118 118
119 /* Allocate frame */ 119 /* Allocate frame */
120 tx_skb = alloc_skb(64, GFP_ATOMIC); 120 tx_skb = alloc_skb(sizeof(struct snrm_frame) +
121 IRLAP_NEGOCIATION_PARAMS_LEN,
122 GFP_ATOMIC);
121 if (!tx_skb) 123 if (!tx_skb)
122 return; 124 return;
123 125
@@ -136,7 +138,7 @@ void irlap_send_snrm_frame(struct irlap_cb *self, struct qos_info *qos)
136 * If we are establishing a connection then insert QoS paramerters 138 * If we are establishing a connection then insert QoS paramerters
137 */ 139 */
138 if (qos) { 140 if (qos) {
139 skb_put(tx_skb, 9); /* 21 left */ 141 skb_put(tx_skb, 9); /* 25 left */
140 frame->saddr = cpu_to_le32(self->saddr); 142 frame->saddr = cpu_to_le32(self->saddr);
141 frame->daddr = cpu_to_le32(self->daddr); 143 frame->daddr = cpu_to_le32(self->daddr);
142 144
@@ -210,7 +212,9 @@ void irlap_send_ua_response_frame(struct irlap_cb *self, struct qos_info *qos)
210 IRDA_ASSERT(self->magic == LAP_MAGIC, return;); 212 IRDA_ASSERT(self->magic == LAP_MAGIC, return;);
211 213
212 /* Allocate frame */ 214 /* Allocate frame */
213 tx_skb = alloc_skb(64, GFP_ATOMIC); 215 tx_skb = alloc_skb(sizeof(struct ua_frame) +
216 IRLAP_NEGOCIATION_PARAMS_LEN,
217 GFP_ATOMIC);
214 if (!tx_skb) 218 if (!tx_skb)
215 return; 219 return;
216 220
@@ -245,23 +249,23 @@ void irlap_send_ua_response_frame(struct irlap_cb *self, struct qos_info *qos)
245void irlap_send_dm_frame( struct irlap_cb *self) 249void irlap_send_dm_frame( struct irlap_cb *self)
246{ 250{
247 struct sk_buff *tx_skb = NULL; 251 struct sk_buff *tx_skb = NULL;
248 __u8 *frame; 252 struct dm_frame *frame;
249 253
250 IRDA_ASSERT(self != NULL, return;); 254 IRDA_ASSERT(self != NULL, return;);
251 IRDA_ASSERT(self->magic == LAP_MAGIC, return;); 255 IRDA_ASSERT(self->magic == LAP_MAGIC, return;);
252 256
253 tx_skb = alloc_skb(32, GFP_ATOMIC); 257 tx_skb = alloc_skb(sizeof(struct dm_frame), GFP_ATOMIC);
254 if (!tx_skb) 258 if (!tx_skb)
255 return; 259 return;
256 260
257 frame = skb_put(tx_skb, 2); 261 frame = (struct dm_frame *)skb_put(tx_skb, 2);
258 262
259 if (self->state == LAP_NDM) 263 if (self->state == LAP_NDM)
260 frame[0] = CBROADCAST; 264 frame->caddr = CBROADCAST;
261 else 265 else
262 frame[0] = self->caddr; 266 frame->caddr = self->caddr;
263 267
264 frame[1] = DM_RSP | PF_BIT; 268 frame->control = DM_RSP | PF_BIT;
265 269
266 irlap_queue_xmit(self, tx_skb); 270 irlap_queue_xmit(self, tx_skb);
267} 271}
@@ -275,21 +279,21 @@ void irlap_send_dm_frame( struct irlap_cb *self)
275void irlap_send_disc_frame(struct irlap_cb *self) 279void irlap_send_disc_frame(struct irlap_cb *self)
276{ 280{
277 struct sk_buff *tx_skb = NULL; 281 struct sk_buff *tx_skb = NULL;
278 __u8 *frame; 282 struct disc_frame *frame;
279 283
280 IRDA_DEBUG(3, "%s()\n", __FUNCTION__); 284 IRDA_DEBUG(3, "%s()\n", __FUNCTION__);
281 285
282 IRDA_ASSERT(self != NULL, return;); 286 IRDA_ASSERT(self != NULL, return;);
283 IRDA_ASSERT(self->magic == LAP_MAGIC, return;); 287 IRDA_ASSERT(self->magic == LAP_MAGIC, return;);
284 288
285 tx_skb = alloc_skb(16, GFP_ATOMIC); 289 tx_skb = alloc_skb(sizeof(struct disc_frame), GFP_ATOMIC);
286 if (!tx_skb) 290 if (!tx_skb)
287 return; 291 return;
288 292
289 frame = skb_put(tx_skb, 2); 293 frame = (struct disc_frame *)skb_put(tx_skb, 2);
290 294
291 frame[0] = self->caddr | CMD_FRAME; 295 frame->caddr = self->caddr | CMD_FRAME;
292 frame[1] = DISC_CMD | PF_BIT; 296 frame->control = DISC_CMD | PF_BIT;
293 297
294 irlap_queue_xmit(self, tx_skb); 298 irlap_queue_xmit(self, tx_skb);
295} 299}
@@ -315,7 +319,8 @@ void irlap_send_discovery_xid_frame(struct irlap_cb *self, int S, __u8 s,
315 IRDA_ASSERT(self->magic == LAP_MAGIC, return;); 319 IRDA_ASSERT(self->magic == LAP_MAGIC, return;);
316 IRDA_ASSERT(discovery != NULL, return;); 320 IRDA_ASSERT(discovery != NULL, return;);
317 321
318 tx_skb = alloc_skb(64, GFP_ATOMIC); 322 tx_skb = alloc_skb(sizeof(struct xid_frame) + IRLAP_DISCOVERY_INFO_LEN,
323 GFP_ATOMIC);
319 if (!tx_skb) 324 if (!tx_skb)
320 return; 325 return;
321 326
@@ -573,18 +578,18 @@ static void irlap_recv_discovery_xid_cmd(struct irlap_cb *self,
573void irlap_send_rr_frame(struct irlap_cb *self, int command) 578void irlap_send_rr_frame(struct irlap_cb *self, int command)
574{ 579{
575 struct sk_buff *tx_skb; 580 struct sk_buff *tx_skb;
576 __u8 *frame; 581 struct rr_frame *frame;
577 582
578 tx_skb = alloc_skb(16, GFP_ATOMIC); 583 tx_skb = alloc_skb(sizeof(struct rr_frame), GFP_ATOMIC);
579 if (!tx_skb) 584 if (!tx_skb)
580 return; 585 return;
581 586
582 frame = skb_put(tx_skb, 2); 587 frame = (struct rr_frame *)skb_put(tx_skb, 2);
583 588
584 frame[0] = self->caddr; 589 frame->caddr = self->caddr;
585 frame[0] |= (command) ? CMD_FRAME : 0; 590 frame->caddr |= (command) ? CMD_FRAME : 0;
586 591
587 frame[1] = RR | PF_BIT | (self->vr << 5); 592 frame->control = RR | PF_BIT | (self->vr << 5);
588 593
589 irlap_queue_xmit(self, tx_skb); 594 irlap_queue_xmit(self, tx_skb);
590} 595}
@@ -598,16 +603,16 @@ void irlap_send_rr_frame(struct irlap_cb *self, int command)
598void irlap_send_rd_frame(struct irlap_cb *self) 603void irlap_send_rd_frame(struct irlap_cb *self)
599{ 604{
600 struct sk_buff *tx_skb; 605 struct sk_buff *tx_skb;
601 __u8 *frame; 606 struct rd_frame *frame;
602 607
603 tx_skb = alloc_skb(16, GFP_ATOMIC); 608 tx_skb = alloc_skb(sizeof(struct rd_frame), GFP_ATOMIC);
604 if (!tx_skb) 609 if (!tx_skb)
605 return; 610 return;
606 611
607 frame = skb_put(tx_skb, 2); 612 frame = (struct rd_frame *)skb_put(tx_skb, 2);
608 613
609 frame[0] = self->caddr; 614 frame->caddr = self->caddr;
610 frame[1] = RD_RSP | PF_BIT; 615 frame->caddr = RD_RSP | PF_BIT;
611 616
612 irlap_queue_xmit(self, tx_skb); 617 irlap_queue_xmit(self, tx_skb);
613} 618}
@@ -1214,7 +1219,7 @@ void irlap_send_test_frame(struct irlap_cb *self, __u8 caddr, __u32 daddr,
1214 struct test_frame *frame; 1219 struct test_frame *frame;
1215 __u8 *info; 1220 __u8 *info;
1216 1221
1217 tx_skb = alloc_skb(cmd->len+sizeof(struct test_frame), GFP_ATOMIC); 1222 tx_skb = alloc_skb(cmd->len + sizeof(struct test_frame), GFP_ATOMIC);
1218 if (!tx_skb) 1223 if (!tx_skb)
1219 return; 1224 return;
1220 1225
diff --git a/net/irda/irlmp.c b/net/irda/irlmp.c
index c440913dee14..5073261b9d0c 100644
--- a/net/irda/irlmp.c
+++ b/net/irda/irlmp.c
@@ -392,7 +392,7 @@ int irlmp_connect_request(struct lsap_cb *self, __u8 dlsap_sel,
392 392
393 /* Any userdata? */ 393 /* Any userdata? */
394 if (tx_skb == NULL) { 394 if (tx_skb == NULL) {
395 tx_skb = alloc_skb(64, GFP_ATOMIC); 395 tx_skb = alloc_skb(LMP_MAX_HEADER, GFP_ATOMIC);
396 if (!tx_skb) 396 if (!tx_skb)
397 return -ENOMEM; 397 return -ENOMEM;
398 398
diff --git a/net/irda/irttp.c b/net/irda/irttp.c
index 42acf1cde737..3c2e70b77df1 100644
--- a/net/irda/irttp.c
+++ b/net/irda/irttp.c
@@ -804,12 +804,12 @@ static inline void irttp_give_credit(struct tsap_cb *self)
804 self->send_credit, self->avail_credit, self->remote_credit); 804 self->send_credit, self->avail_credit, self->remote_credit);
805 805
806 /* Give credit to peer */ 806 /* Give credit to peer */
807 tx_skb = alloc_skb(64, GFP_ATOMIC); 807 tx_skb = alloc_skb(TTP_MAX_HEADER, GFP_ATOMIC);
808 if (!tx_skb) 808 if (!tx_skb)
809 return; 809 return;
810 810
811 /* Reserve space for LMP, and LAP header */ 811 /* Reserve space for LMP, and LAP header */
812 skb_reserve(tx_skb, self->max_header_size); 812 skb_reserve(tx_skb, LMP_MAX_HEADER);
813 813
814 /* 814 /*
815 * Since we can transmit and receive frames concurrently, 815 * Since we can transmit and receive frames concurrently,
@@ -1093,7 +1093,8 @@ int irttp_connect_request(struct tsap_cb *self, __u8 dtsap_sel,
1093 1093
1094 /* Any userdata supplied? */ 1094 /* Any userdata supplied? */
1095 if (userdata == NULL) { 1095 if (userdata == NULL) {
1096 tx_skb = alloc_skb(64, GFP_ATOMIC); 1096 tx_skb = alloc_skb(TTP_MAX_HEADER + TTP_SAR_HEADER,
1097 GFP_ATOMIC);
1097 if (!tx_skb) 1098 if (!tx_skb)
1098 return -ENOMEM; 1099 return -ENOMEM;
1099 1100
@@ -1341,7 +1342,8 @@ int irttp_connect_response(struct tsap_cb *self, __u32 max_sdu_size,
1341 1342
1342 /* Any userdata supplied? */ 1343 /* Any userdata supplied? */
1343 if (userdata == NULL) { 1344 if (userdata == NULL) {
1344 tx_skb = alloc_skb(64, GFP_ATOMIC); 1345 tx_skb = alloc_skb(TTP_MAX_HEADER + TTP_SAR_HEADER,
1346 GFP_ATOMIC);
1345 if (!tx_skb) 1347 if (!tx_skb)
1346 return -ENOMEM; 1348 return -ENOMEM;
1347 1349
@@ -1540,14 +1542,14 @@ int irttp_disconnect_request(struct tsap_cb *self, struct sk_buff *userdata,
1540 1542
1541 if (!userdata) { 1543 if (!userdata) {
1542 struct sk_buff *tx_skb; 1544 struct sk_buff *tx_skb;
1543 tx_skb = alloc_skb(64, GFP_ATOMIC); 1545 tx_skb = alloc_skb(LMP_MAX_HEADER, GFP_ATOMIC);
1544 if (!tx_skb) 1546 if (!tx_skb)
1545 return -ENOMEM; 1547 return -ENOMEM;
1546 1548
1547 /* 1549 /*
1548 * Reserve space for MUX and LAP header 1550 * Reserve space for MUX and LAP header
1549 */ 1551 */
1550 skb_reserve(tx_skb, TTP_MAX_HEADER); 1552 skb_reserve(tx_skb, LMP_MAX_HEADER);
1551 1553
1552 userdata = tx_skb; 1554 userdata = tx_skb;
1553 } 1555 }
diff --git a/net/key/af_key.c b/net/key/af_key.c
index 83b443ddc72f..ff98e70b0931 100644
--- a/net/key/af_key.c
+++ b/net/key/af_key.c
@@ -2140,7 +2140,7 @@ static int pfkey_spdadd(struct sock *sk, struct sk_buff *skb, struct sadb_msg *h
2140 xp->selector.proto = pfkey_proto_to_xfrm(sa->sadb_address_proto); 2140 xp->selector.proto = pfkey_proto_to_xfrm(sa->sadb_address_proto);
2141 xp->selector.sport = ((struct sockaddr_in *)(sa+1))->sin_port; 2141 xp->selector.sport = ((struct sockaddr_in *)(sa+1))->sin_port;
2142 if (xp->selector.sport) 2142 if (xp->selector.sport)
2143 xp->selector.sport_mask = ~0; 2143 xp->selector.sport_mask = htons(0xffff);
2144 2144
2145 sa = ext_hdrs[SADB_EXT_ADDRESS_DST-1], 2145 sa = ext_hdrs[SADB_EXT_ADDRESS_DST-1],
2146 pfkey_sadb_addr2xfrm_addr(sa, &xp->selector.daddr); 2146 pfkey_sadb_addr2xfrm_addr(sa, &xp->selector.daddr);
@@ -2153,7 +2153,7 @@ static int pfkey_spdadd(struct sock *sk, struct sk_buff *skb, struct sadb_msg *h
2153 2153
2154 xp->selector.dport = ((struct sockaddr_in *)(sa+1))->sin_port; 2154 xp->selector.dport = ((struct sockaddr_in *)(sa+1))->sin_port;
2155 if (xp->selector.dport) 2155 if (xp->selector.dport)
2156 xp->selector.dport_mask = ~0; 2156 xp->selector.dport_mask = htons(0xffff);
2157 2157
2158 sec_ctx = (struct sadb_x_sec_ctx *) ext_hdrs[SADB_X_EXT_SEC_CTX-1]; 2158 sec_ctx = (struct sadb_x_sec_ctx *) ext_hdrs[SADB_X_EXT_SEC_CTX-1];
2159 if (sec_ctx != NULL) { 2159 if (sec_ctx != NULL) {
@@ -2243,7 +2243,7 @@ static int pfkey_spddelete(struct sock *sk, struct sk_buff *skb, struct sadb_msg
2243 sel.proto = pfkey_proto_to_xfrm(sa->sadb_address_proto); 2243 sel.proto = pfkey_proto_to_xfrm(sa->sadb_address_proto);
2244 sel.sport = ((struct sockaddr_in *)(sa+1))->sin_port; 2244 sel.sport = ((struct sockaddr_in *)(sa+1))->sin_port;
2245 if (sel.sport) 2245 if (sel.sport)
2246 sel.sport_mask = ~0; 2246 sel.sport_mask = htons(0xffff);
2247 2247
2248 sa = ext_hdrs[SADB_EXT_ADDRESS_DST-1], 2248 sa = ext_hdrs[SADB_EXT_ADDRESS_DST-1],
2249 pfkey_sadb_addr2xfrm_addr(sa, &sel.daddr); 2249 pfkey_sadb_addr2xfrm_addr(sa, &sel.daddr);
@@ -2251,7 +2251,7 @@ static int pfkey_spddelete(struct sock *sk, struct sk_buff *skb, struct sadb_msg
2251 sel.proto = pfkey_proto_to_xfrm(sa->sadb_address_proto); 2251 sel.proto = pfkey_proto_to_xfrm(sa->sadb_address_proto);
2252 sel.dport = ((struct sockaddr_in *)(sa+1))->sin_port; 2252 sel.dport = ((struct sockaddr_in *)(sa+1))->sin_port;
2253 if (sel.dport) 2253 if (sel.dport)
2254 sel.dport_mask = ~0; 2254 sel.dport_mask = htons(0xffff);
2255 2255
2256 sec_ctx = (struct sadb_x_sec_ctx *) ext_hdrs[SADB_X_EXT_SEC_CTX-1]; 2256 sec_ctx = (struct sadb_x_sec_ctx *) ext_hdrs[SADB_X_EXT_SEC_CTX-1];
2257 memset(&tmp, 0, sizeof(struct xfrm_policy)); 2257 memset(&tmp, 0, sizeof(struct xfrm_policy));
diff --git a/net/netlabel/netlabel_cipso_v4.c b/net/netlabel/netlabel_cipso_v4.c
index 4125a55f469f..09986ca962a6 100644
--- a/net/netlabel/netlabel_cipso_v4.c
+++ b/net/netlabel/netlabel_cipso_v4.c
@@ -32,6 +32,7 @@
32#include <linux/socket.h> 32#include <linux/socket.h>
33#include <linux/string.h> 33#include <linux/string.h>
34#include <linux/skbuff.h> 34#include <linux/skbuff.h>
35#include <linux/audit.h>
35#include <net/sock.h> 36#include <net/sock.h>
36#include <net/netlink.h> 37#include <net/netlink.h>
37#include <net/genetlink.h> 38#include <net/genetlink.h>
@@ -162,8 +163,7 @@ static int netlbl_cipsov4_add_std(struct genl_info *info)
162 int nla_a_rem; 163 int nla_a_rem;
163 int nla_b_rem; 164 int nla_b_rem;
164 165
165 if (!info->attrs[NLBL_CIPSOV4_A_DOI] || 166 if (!info->attrs[NLBL_CIPSOV4_A_TAGLST] ||
166 !info->attrs[NLBL_CIPSOV4_A_TAGLST] ||
167 !info->attrs[NLBL_CIPSOV4_A_MLSLVLLST]) 167 !info->attrs[NLBL_CIPSOV4_A_MLSLVLLST])
168 return -EINVAL; 168 return -EINVAL;
169 169
@@ -344,8 +344,7 @@ static int netlbl_cipsov4_add_pass(struct genl_info *info)
344 int ret_val; 344 int ret_val;
345 struct cipso_v4_doi *doi_def = NULL; 345 struct cipso_v4_doi *doi_def = NULL;
346 346
347 if (!info->attrs[NLBL_CIPSOV4_A_DOI] || 347 if (!info->attrs[NLBL_CIPSOV4_A_TAGLST])
348 !info->attrs[NLBL_CIPSOV4_A_TAGLST])
349 return -EINVAL; 348 return -EINVAL;
350 349
351 doi_def = kmalloc(sizeof(*doi_def), GFP_KERNEL); 350 doi_def = kmalloc(sizeof(*doi_def), GFP_KERNEL);
@@ -381,21 +380,35 @@ static int netlbl_cipsov4_add(struct sk_buff *skb, struct genl_info *info)
381 380
382{ 381{
383 int ret_val = -EINVAL; 382 int ret_val = -EINVAL;
384 u32 map_type; 383 u32 type;
384 u32 doi;
385 const char *type_str = "(unknown)";
386 struct audit_buffer *audit_buf;
385 387
386 if (!info->attrs[NLBL_CIPSOV4_A_MTYPE]) 388 if (!info->attrs[NLBL_CIPSOV4_A_DOI] ||
389 !info->attrs[NLBL_CIPSOV4_A_MTYPE])
387 return -EINVAL; 390 return -EINVAL;
388 391
389 map_type = nla_get_u32(info->attrs[NLBL_CIPSOV4_A_MTYPE]); 392 type = nla_get_u32(info->attrs[NLBL_CIPSOV4_A_MTYPE]);
390 switch (map_type) { 393 switch (type) {
391 case CIPSO_V4_MAP_STD: 394 case CIPSO_V4_MAP_STD:
395 type_str = "std";
392 ret_val = netlbl_cipsov4_add_std(info); 396 ret_val = netlbl_cipsov4_add_std(info);
393 break; 397 break;
394 case CIPSO_V4_MAP_PASS: 398 case CIPSO_V4_MAP_PASS:
399 type_str = "pass";
395 ret_val = netlbl_cipsov4_add_pass(info); 400 ret_val = netlbl_cipsov4_add_pass(info);
396 break; 401 break;
397 } 402 }
398 403
404 if (ret_val == 0) {
405 doi = nla_get_u32(info->attrs[NLBL_CIPSOV4_A_DOI]);
406 audit_buf = netlbl_audit_start_common(AUDIT_MAC_CIPSOV4_ADD,
407 NETLINK_CB(skb).sid);
408 audit_log_format(audit_buf, " doi=%u type=%s", doi, type_str);
409 audit_log_end(audit_buf);
410 }
411
399 return ret_val; 412 return ret_val;
400} 413}
401 414
@@ -653,11 +666,21 @@ static int netlbl_cipsov4_listall(struct sk_buff *skb,
653static int netlbl_cipsov4_remove(struct sk_buff *skb, struct genl_info *info) 666static int netlbl_cipsov4_remove(struct sk_buff *skb, struct genl_info *info)
654{ 667{
655 int ret_val = -EINVAL; 668 int ret_val = -EINVAL;
656 u32 doi; 669 u32 doi = 0;
670 struct audit_buffer *audit_buf;
657 671
658 if (info->attrs[NLBL_CIPSOV4_A_DOI]) { 672 if (info->attrs[NLBL_CIPSOV4_A_DOI]) {
659 doi = nla_get_u32(info->attrs[NLBL_CIPSOV4_A_DOI]); 673 doi = nla_get_u32(info->attrs[NLBL_CIPSOV4_A_DOI]);
660 ret_val = cipso_v4_doi_remove(doi, netlbl_cipsov4_doi_free); 674 ret_val = cipso_v4_doi_remove(doi,
675 NETLINK_CB(skb).sid,
676 netlbl_cipsov4_doi_free);
677 }
678
679 if (ret_val == 0) {
680 audit_buf = netlbl_audit_start_common(AUDIT_MAC_CIPSOV4_DEL,
681 NETLINK_CB(skb).sid);
682 audit_log_format(audit_buf, " doi=%u", doi);
683 audit_log_end(audit_buf);
661 } 684 }
662 685
663 return ret_val; 686 return ret_val;
diff --git a/net/netlabel/netlabel_domainhash.c b/net/netlabel/netlabel_domainhash.c
index f56d7a8ac7b7..d64e2ae3b129 100644
--- a/net/netlabel/netlabel_domainhash.c
+++ b/net/netlabel/netlabel_domainhash.c
@@ -35,12 +35,14 @@
35#include <linux/skbuff.h> 35#include <linux/skbuff.h>
36#include <linux/spinlock.h> 36#include <linux/spinlock.h>
37#include <linux/string.h> 37#include <linux/string.h>
38#include <linux/audit.h>
38#include <net/netlabel.h> 39#include <net/netlabel.h>
39#include <net/cipso_ipv4.h> 40#include <net/cipso_ipv4.h>
40#include <asm/bug.h> 41#include <asm/bug.h>
41 42
42#include "netlabel_mgmt.h" 43#include "netlabel_mgmt.h"
43#include "netlabel_domainhash.h" 44#include "netlabel_domainhash.h"
45#include "netlabel_user.h"
44 46
45struct netlbl_domhsh_tbl { 47struct netlbl_domhsh_tbl {
46 struct list_head *tbl; 48 struct list_head *tbl;
@@ -186,6 +188,7 @@ int netlbl_domhsh_init(u32 size)
186/** 188/**
187 * netlbl_domhsh_add - Adds a entry to the domain hash table 189 * netlbl_domhsh_add - Adds a entry to the domain hash table
188 * @entry: the entry to add 190 * @entry: the entry to add
191 * @audit_secid: the LSM secid to use in the audit message
189 * 192 *
190 * Description: 193 * Description:
191 * Adds a new entry to the domain hash table and handles any updates to the 194 * Adds a new entry to the domain hash table and handles any updates to the
@@ -193,10 +196,12 @@ int netlbl_domhsh_init(u32 size)
193 * negative on failure. 196 * negative on failure.
194 * 197 *
195 */ 198 */
196int netlbl_domhsh_add(struct netlbl_dom_map *entry) 199int netlbl_domhsh_add(struct netlbl_dom_map *entry, u32 audit_secid)
197{ 200{
198 int ret_val; 201 int ret_val;
199 u32 bkt; 202 u32 bkt;
203 struct audit_buffer *audit_buf;
204 char *audit_domain;
200 205
201 switch (entry->type) { 206 switch (entry->type) {
202 case NETLBL_NLTYPE_UNLABELED: 207 case NETLBL_NLTYPE_UNLABELED:
@@ -236,6 +241,26 @@ int netlbl_domhsh_add(struct netlbl_dom_map *entry)
236 spin_unlock(&netlbl_domhsh_def_lock); 241 spin_unlock(&netlbl_domhsh_def_lock);
237 } else 242 } else
238 ret_val = -EINVAL; 243 ret_val = -EINVAL;
244 if (ret_val == 0) {
245 if (entry->domain != NULL)
246 audit_domain = entry->domain;
247 else
248 audit_domain = "(default)";
249 audit_buf = netlbl_audit_start_common(AUDIT_MAC_MAP_ADD,
250 audit_secid);
251 audit_log_format(audit_buf, " domain=%s", audit_domain);
252 switch (entry->type) {
253 case NETLBL_NLTYPE_UNLABELED:
254 audit_log_format(audit_buf, " protocol=unlbl");
255 break;
256 case NETLBL_NLTYPE_CIPSOV4:
257 audit_log_format(audit_buf,
258 " protocol=cipsov4 doi=%u",
259 entry->type_def.cipsov4->doi);
260 break;
261 }
262 audit_log_end(audit_buf);
263 }
239 rcu_read_unlock(); 264 rcu_read_unlock();
240 265
241 if (ret_val != 0) { 266 if (ret_val != 0) {
@@ -254,6 +279,7 @@ int netlbl_domhsh_add(struct netlbl_dom_map *entry)
254/** 279/**
255 * netlbl_domhsh_add_default - Adds the default entry to the domain hash table 280 * netlbl_domhsh_add_default - Adds the default entry to the domain hash table
256 * @entry: the entry to add 281 * @entry: the entry to add
282 * @audit_secid: the LSM secid to use in the audit message
257 * 283 *
258 * Description: 284 * Description:
259 * Adds a new default entry to the domain hash table and handles any updates 285 * Adds a new default entry to the domain hash table and handles any updates
@@ -261,14 +287,15 @@ int netlbl_domhsh_add(struct netlbl_dom_map *entry)
261 * negative on failure. 287 * negative on failure.
262 * 288 *
263 */ 289 */
264int netlbl_domhsh_add_default(struct netlbl_dom_map *entry) 290int netlbl_domhsh_add_default(struct netlbl_dom_map *entry, u32 audit_secid)
265{ 291{
266 return netlbl_domhsh_add(entry); 292 return netlbl_domhsh_add(entry, audit_secid);
267} 293}
268 294
269/** 295/**
270 * netlbl_domhsh_remove - Removes an entry from the domain hash table 296 * netlbl_domhsh_remove - Removes an entry from the domain hash table
271 * @domain: the domain to remove 297 * @domain: the domain to remove
298 * @audit_secid: the LSM secid to use in the audit message
272 * 299 *
273 * Description: 300 * Description:
274 * Removes an entry from the domain hash table and handles any updates to the 301 * Removes an entry from the domain hash table and handles any updates to the
@@ -276,10 +303,12 @@ int netlbl_domhsh_add_default(struct netlbl_dom_map *entry)
276 * negative on failure. 303 * negative on failure.
277 * 304 *
278 */ 305 */
279int netlbl_domhsh_remove(const char *domain) 306int netlbl_domhsh_remove(const char *domain, u32 audit_secid)
280{ 307{
281 int ret_val = -ENOENT; 308 int ret_val = -ENOENT;
282 struct netlbl_dom_map *entry; 309 struct netlbl_dom_map *entry;
310 struct audit_buffer *audit_buf;
311 char *audit_domain;
283 312
284 rcu_read_lock(); 313 rcu_read_lock();
285 if (domain != NULL) 314 if (domain != NULL)
@@ -316,8 +345,18 @@ int netlbl_domhsh_remove(const char *domain)
316 ret_val = -ENOENT; 345 ret_val = -ENOENT;
317 spin_unlock(&netlbl_domhsh_def_lock); 346 spin_unlock(&netlbl_domhsh_def_lock);
318 } 347 }
319 if (ret_val == 0) 348 if (ret_val == 0) {
349 if (entry->domain != NULL)
350 audit_domain = entry->domain;
351 else
352 audit_domain = "(default)";
353 audit_buf = netlbl_audit_start_common(AUDIT_MAC_MAP_DEL,
354 audit_secid);
355 audit_log_format(audit_buf, " domain=%s", audit_domain);
356 audit_log_end(audit_buf);
357
320 call_rcu(&entry->rcu, netlbl_domhsh_free_entry); 358 call_rcu(&entry->rcu, netlbl_domhsh_free_entry);
359 }
321 360
322remove_return: 361remove_return:
323 rcu_read_unlock(); 362 rcu_read_unlock();
@@ -326,6 +365,7 @@ remove_return:
326 365
327/** 366/**
328 * netlbl_domhsh_remove_default - Removes the default entry from the table 367 * netlbl_domhsh_remove_default - Removes the default entry from the table
368 * @audit_secid: the LSM secid to use in the audit message
329 * 369 *
330 * Description: 370 * Description:
331 * Removes/resets the default entry for the domain hash table and handles any 371 * Removes/resets the default entry for the domain hash table and handles any
@@ -333,9 +373,9 @@ remove_return:
333 * success, non-zero on failure. 373 * success, non-zero on failure.
334 * 374 *
335 */ 375 */
336int netlbl_domhsh_remove_default(void) 376int netlbl_domhsh_remove_default(u32 audit_secid)
337{ 377{
338 return netlbl_domhsh_remove(NULL); 378 return netlbl_domhsh_remove(NULL, audit_secid);
339} 379}
340 380
341/** 381/**
diff --git a/net/netlabel/netlabel_domainhash.h b/net/netlabel/netlabel_domainhash.h
index 02af72a7877c..d50f13cacdca 100644
--- a/net/netlabel/netlabel_domainhash.h
+++ b/net/netlabel/netlabel_domainhash.h
@@ -57,9 +57,9 @@ struct netlbl_dom_map {
57int netlbl_domhsh_init(u32 size); 57int netlbl_domhsh_init(u32 size);
58 58
59/* Manipulate the domain hash table */ 59/* Manipulate the domain hash table */
60int netlbl_domhsh_add(struct netlbl_dom_map *entry); 60int netlbl_domhsh_add(struct netlbl_dom_map *entry, u32 audit_secid);
61int netlbl_domhsh_add_default(struct netlbl_dom_map *entry); 61int netlbl_domhsh_add_default(struct netlbl_dom_map *entry, u32 audit_secid);
62int netlbl_domhsh_remove_default(void); 62int netlbl_domhsh_remove_default(u32 audit_secid);
63struct netlbl_dom_map *netlbl_domhsh_getentry(const char *domain); 63struct netlbl_dom_map *netlbl_domhsh_getentry(const char *domain);
64int netlbl_domhsh_walk(u32 *skip_bkt, 64int netlbl_domhsh_walk(u32 *skip_bkt,
65 u32 *skip_chain, 65 u32 *skip_chain,
diff --git a/net/netlabel/netlabel_mgmt.c b/net/netlabel/netlabel_mgmt.c
index 8626c9f678eb..0ac314f18ad1 100644
--- a/net/netlabel/netlabel_mgmt.c
+++ b/net/netlabel/netlabel_mgmt.c
@@ -108,7 +108,7 @@ static int netlbl_mgmt_add(struct sk_buff *skb, struct genl_info *info)
108 108
109 switch (entry->type) { 109 switch (entry->type) {
110 case NETLBL_NLTYPE_UNLABELED: 110 case NETLBL_NLTYPE_UNLABELED:
111 ret_val = netlbl_domhsh_add(entry); 111 ret_val = netlbl_domhsh_add(entry, NETLINK_CB(skb).sid);
112 break; 112 break;
113 case NETLBL_NLTYPE_CIPSOV4: 113 case NETLBL_NLTYPE_CIPSOV4:
114 if (!info->attrs[NLBL_MGMT_A_CV4DOI]) 114 if (!info->attrs[NLBL_MGMT_A_CV4DOI])
@@ -125,7 +125,7 @@ static int netlbl_mgmt_add(struct sk_buff *skb, struct genl_info *info)
125 rcu_read_unlock(); 125 rcu_read_unlock();
126 goto add_failure; 126 goto add_failure;
127 } 127 }
128 ret_val = netlbl_domhsh_add(entry); 128 ret_val = netlbl_domhsh_add(entry, NETLINK_CB(skb).sid);
129 rcu_read_unlock(); 129 rcu_read_unlock();
130 break; 130 break;
131 default: 131 default:
@@ -161,7 +161,7 @@ static int netlbl_mgmt_remove(struct sk_buff *skb, struct genl_info *info)
161 return -EINVAL; 161 return -EINVAL;
162 162
163 domain = nla_data(info->attrs[NLBL_MGMT_A_DOMAIN]); 163 domain = nla_data(info->attrs[NLBL_MGMT_A_DOMAIN]);
164 return netlbl_domhsh_remove(domain); 164 return netlbl_domhsh_remove(domain, NETLINK_CB(skb).sid);
165} 165}
166 166
167/** 167/**
@@ -277,7 +277,8 @@ static int netlbl_mgmt_adddef(struct sk_buff *skb, struct genl_info *info)
277 277
278 switch (entry->type) { 278 switch (entry->type) {
279 case NETLBL_NLTYPE_UNLABELED: 279 case NETLBL_NLTYPE_UNLABELED:
280 ret_val = netlbl_domhsh_add_default(entry); 280 ret_val = netlbl_domhsh_add_default(entry,
281 NETLINK_CB(skb).sid);
281 break; 282 break;
282 case NETLBL_NLTYPE_CIPSOV4: 283 case NETLBL_NLTYPE_CIPSOV4:
283 if (!info->attrs[NLBL_MGMT_A_CV4DOI]) 284 if (!info->attrs[NLBL_MGMT_A_CV4DOI])
@@ -294,7 +295,8 @@ static int netlbl_mgmt_adddef(struct sk_buff *skb, struct genl_info *info)
294 rcu_read_unlock(); 295 rcu_read_unlock();
295 goto adddef_failure; 296 goto adddef_failure;
296 } 297 }
297 ret_val = netlbl_domhsh_add_default(entry); 298 ret_val = netlbl_domhsh_add_default(entry,
299 NETLINK_CB(skb).sid);
298 rcu_read_unlock(); 300 rcu_read_unlock();
299 break; 301 break;
300 default: 302 default:
@@ -322,7 +324,7 @@ adddef_failure:
322 */ 324 */
323static int netlbl_mgmt_removedef(struct sk_buff *skb, struct genl_info *info) 325static int netlbl_mgmt_removedef(struct sk_buff *skb, struct genl_info *info)
324{ 326{
325 return netlbl_domhsh_remove_default(); 327 return netlbl_domhsh_remove_default(NETLINK_CB(skb).sid);
326} 328}
327 329
328/** 330/**
diff --git a/net/netlabel/netlabel_unlabeled.c b/net/netlabel/netlabel_unlabeled.c
index 440f5c4e1e2d..ab36675fee8c 100644
--- a/net/netlabel/netlabel_unlabeled.c
+++ b/net/netlabel/netlabel_unlabeled.c
@@ -64,6 +64,27 @@ static struct nla_policy netlbl_unlabel_genl_policy[NLBL_UNLABEL_A_MAX + 1] = {
64}; 64};
65 65
66/* 66/*
67 * Helper Functions
68 */
69
70/**
71 * netlbl_unlabel_acceptflg_set - Set the unlabeled accept flag
72 * @value: desired value
73 * @audit_secid: the LSM secid to use in the audit message
74 *
75 * Description:
76 * Set the value of the unlabeled accept flag to @value.
77 *
78 */
79static void netlbl_unlabel_acceptflg_set(u8 value, u32 audit_secid)
80{
81 atomic_set(&netlabel_unlabel_accept_flg, value);
82 netlbl_audit_nomsg((value ?
83 AUDIT_MAC_UNLBL_ACCEPT : AUDIT_MAC_UNLBL_DENY),
84 audit_secid);
85}
86
87/*
67 * NetLabel Command Handlers 88 * NetLabel Command Handlers
68 */ 89 */
69 90
@@ -79,18 +100,18 @@ static struct nla_policy netlbl_unlabel_genl_policy[NLBL_UNLABEL_A_MAX + 1] = {
79 */ 100 */
80static int netlbl_unlabel_accept(struct sk_buff *skb, struct genl_info *info) 101static int netlbl_unlabel_accept(struct sk_buff *skb, struct genl_info *info)
81{ 102{
82 int ret_val = -EINVAL;
83 u8 value; 103 u8 value;
84 104
85 if (info->attrs[NLBL_UNLABEL_A_ACPTFLG]) { 105 if (info->attrs[NLBL_UNLABEL_A_ACPTFLG]) {
86 value = nla_get_u8(info->attrs[NLBL_UNLABEL_A_ACPTFLG]); 106 value = nla_get_u8(info->attrs[NLBL_UNLABEL_A_ACPTFLG]);
87 if (value == 1 || value == 0) { 107 if (value == 1 || value == 0) {
88 atomic_set(&netlabel_unlabel_accept_flg, value); 108 netlbl_unlabel_acceptflg_set(value,
89 ret_val = 0; 109 NETLINK_CB(skb).sid);
110 return 0;
90 } 111 }
91 } 112 }
92 113
93 return ret_val; 114 return -EINVAL;
94} 115}
95 116
96/** 117/**
@@ -229,16 +250,19 @@ int netlbl_unlabel_defconf(void)
229{ 250{
230 int ret_val; 251 int ret_val;
231 struct netlbl_dom_map *entry; 252 struct netlbl_dom_map *entry;
253 u32 secid;
254
255 security_task_getsecid(current, &secid);
232 256
233 entry = kzalloc(sizeof(*entry), GFP_KERNEL); 257 entry = kzalloc(sizeof(*entry), GFP_KERNEL);
234 if (entry == NULL) 258 if (entry == NULL)
235 return -ENOMEM; 259 return -ENOMEM;
236 entry->type = NETLBL_NLTYPE_UNLABELED; 260 entry->type = NETLBL_NLTYPE_UNLABELED;
237 ret_val = netlbl_domhsh_add_default(entry); 261 ret_val = netlbl_domhsh_add_default(entry, secid);
238 if (ret_val != 0) 262 if (ret_val != 0)
239 return ret_val; 263 return ret_val;
240 264
241 atomic_set(&netlabel_unlabel_accept_flg, 1); 265 netlbl_unlabel_acceptflg_set(1, secid);
242 266
243 return 0; 267 return 0;
244} 268}
diff --git a/net/netlabel/netlabel_user.c b/net/netlabel/netlabel_user.c
index eeb7d768d2bb..c2343af584cb 100644
--- a/net/netlabel/netlabel_user.c
+++ b/net/netlabel/netlabel_user.c
@@ -32,6 +32,9 @@
32#include <linux/types.h> 32#include <linux/types.h>
33#include <linux/list.h> 33#include <linux/list.h>
34#include <linux/socket.h> 34#include <linux/socket.h>
35#include <linux/audit.h>
36#include <linux/tty.h>
37#include <linux/security.h>
35#include <net/sock.h> 38#include <net/sock.h>
36#include <net/netlink.h> 39#include <net/netlink.h>
37#include <net/genetlink.h> 40#include <net/genetlink.h>
@@ -74,3 +77,91 @@ int netlbl_netlink_init(void)
74 77
75 return 0; 78 return 0;
76} 79}
80
81/*
82 * NetLabel Audit Functions
83 */
84
85/**
86 * netlbl_audit_start_common - Start an audit message
87 * @type: audit message type
88 * @secid: LSM context ID
89 *
90 * Description:
91 * Start an audit message using the type specified in @type and fill the audit
92 * message with some fields common to all NetLabel audit messages. Returns
93 * a pointer to the audit buffer on success, NULL on failure.
94 *
95 */
96struct audit_buffer *netlbl_audit_start_common(int type, u32 secid)
97{
98 struct audit_context *audit_ctx = current->audit_context;
99 struct audit_buffer *audit_buf;
100 uid_t audit_loginuid;
101 const char *audit_tty;
102 char audit_comm[sizeof(current->comm)];
103 struct vm_area_struct *vma;
104 char *secctx;
105 u32 secctx_len;
106
107 audit_buf = audit_log_start(audit_ctx, GFP_ATOMIC, type);
108 if (audit_buf == NULL)
109 return NULL;
110
111 audit_loginuid = audit_get_loginuid(audit_ctx);
112 if (current->signal &&
113 current->signal->tty &&
114 current->signal->tty->name)
115 audit_tty = current->signal->tty->name;
116 else
117 audit_tty = "(none)";
118 get_task_comm(audit_comm, current);
119
120 audit_log_format(audit_buf,
121 "netlabel: auid=%u uid=%u tty=%s pid=%d",
122 audit_loginuid,
123 current->uid,
124 audit_tty,
125 current->pid);
126 audit_log_format(audit_buf, " comm=");
127 audit_log_untrustedstring(audit_buf, audit_comm);
128 if (current->mm) {
129 down_read(&current->mm->mmap_sem);
130 vma = current->mm->mmap;
131 while (vma) {
132 if ((vma->vm_flags & VM_EXECUTABLE) &&
133 vma->vm_file) {
134 audit_log_d_path(audit_buf,
135 " exe=",
136 vma->vm_file->f_dentry,
137 vma->vm_file->f_vfsmnt);
138 break;
139 }
140 vma = vma->vm_next;
141 }
142 up_read(&current->mm->mmap_sem);
143 }
144
145 if (secid != 0 &&
146 security_secid_to_secctx(secid, &secctx, &secctx_len) == 0)
147 audit_log_format(audit_buf, " subj=%s", secctx);
148
149 return audit_buf;
150}
151
152/**
153 * netlbl_audit_nomsg - Send an audit message without additional text
154 * @type: audit message type
155 * @secid: LSM context ID
156 *
157 * Description:
158 * Send an audit message with only the common NetLabel audit fields.
159 *
160 */
161void netlbl_audit_nomsg(int type, u32 secid)
162{
163 struct audit_buffer *audit_buf;
164
165 audit_buf = netlbl_audit_start_common(type, secid);
166 audit_log_end(audit_buf);
167}
diff --git a/net/netlabel/netlabel_user.h b/net/netlabel/netlabel_user.h
index 3f9386b917df..ab840acfc964 100644
--- a/net/netlabel/netlabel_user.h
+++ b/net/netlabel/netlabel_user.h
@@ -34,6 +34,7 @@
34#include <linux/types.h> 34#include <linux/types.h>
35#include <linux/skbuff.h> 35#include <linux/skbuff.h>
36#include <linux/capability.h> 36#include <linux/capability.h>
37#include <linux/audit.h>
37#include <net/netlink.h> 38#include <net/netlink.h>
38#include <net/genetlink.h> 39#include <net/genetlink.h>
39#include <net/netlabel.h> 40#include <net/netlabel.h>
@@ -75,4 +76,9 @@ static inline void *netlbl_netlink_hdr_put(struct sk_buff *skb,
75 76
76int netlbl_netlink_init(void); 77int netlbl_netlink_init(void);
77 78
79/* NetLabel Audit Functions */
80
81struct audit_buffer *netlbl_audit_start_common(int type, u32 secid);
82void netlbl_audit_nomsg(int type, u32 secid);
83
78#endif 84#endif
diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c
index 7e14f14058e9..37a184021647 100644
--- a/net/sched/cls_api.c
+++ b/net/sched/cls_api.c
@@ -401,7 +401,7 @@ static int tc_dump_tfilter(struct sk_buff *skb, struct netlink_callback *cb)
401 if ((dev = dev_get_by_index(tcm->tcm_ifindex)) == NULL) 401 if ((dev = dev_get_by_index(tcm->tcm_ifindex)) == NULL)
402 return skb->len; 402 return skb->len;
403 403
404 read_lock_bh(&qdisc_tree_lock); 404 read_lock(&qdisc_tree_lock);
405 if (!tcm->tcm_parent) 405 if (!tcm->tcm_parent)
406 q = dev->qdisc_sleeping; 406 q = dev->qdisc_sleeping;
407 else 407 else
@@ -458,7 +458,7 @@ errout:
458 if (cl) 458 if (cl)
459 cops->put(q, cl); 459 cops->put(q, cl);
460out: 460out:
461 read_unlock_bh(&qdisc_tree_lock); 461 read_unlock(&qdisc_tree_lock);
462 dev_put(dev); 462 dev_put(dev);
463 return skb->len; 463 return skb->len;
464} 464}
diff --git a/net/sched/cls_basic.c b/net/sched/cls_basic.c
index 86cac49a0531..09fda68c8b39 100644
--- a/net/sched/cls_basic.c
+++ b/net/sched/cls_basic.c
@@ -194,7 +194,7 @@ static int basic_change(struct tcf_proto *tp, unsigned long base, u32 handle,
194 if (handle) 194 if (handle)
195 f->handle = handle; 195 f->handle = handle;
196 else { 196 else {
197 int i = 0x80000000; 197 unsigned int i = 0x80000000;
198 do { 198 do {
199 if (++head->hgenerator == 0x7FFFFFFF) 199 if (++head->hgenerator == 0x7FFFFFFF)
200 head->hgenerator = 1; 200 head->hgenerator = 1;
diff --git a/net/sched/sch_api.c b/net/sched/sch_api.c
index a19eff12cf78..0b6489291140 100644
--- a/net/sched/sch_api.c
+++ b/net/sched/sch_api.c
@@ -195,14 +195,14 @@ struct Qdisc *qdisc_lookup(struct net_device *dev, u32 handle)
195{ 195{
196 struct Qdisc *q; 196 struct Qdisc *q;
197 197
198 read_lock_bh(&qdisc_tree_lock); 198 read_lock(&qdisc_tree_lock);
199 list_for_each_entry(q, &dev->qdisc_list, list) { 199 list_for_each_entry(q, &dev->qdisc_list, list) {
200 if (q->handle == handle) { 200 if (q->handle == handle) {
201 read_unlock_bh(&qdisc_tree_lock); 201 read_unlock(&qdisc_tree_lock);
202 return q; 202 return q;
203 } 203 }
204 } 204 }
205 read_unlock_bh(&qdisc_tree_lock); 205 read_unlock(&qdisc_tree_lock);
206 return NULL; 206 return NULL;
207} 207}
208 208
@@ -837,7 +837,7 @@ static int tc_dump_qdisc(struct sk_buff *skb, struct netlink_callback *cb)
837 continue; 837 continue;
838 if (idx > s_idx) 838 if (idx > s_idx)
839 s_q_idx = 0; 839 s_q_idx = 0;
840 read_lock_bh(&qdisc_tree_lock); 840 read_lock(&qdisc_tree_lock);
841 q_idx = 0; 841 q_idx = 0;
842 list_for_each_entry(q, &dev->qdisc_list, list) { 842 list_for_each_entry(q, &dev->qdisc_list, list) {
843 if (q_idx < s_q_idx) { 843 if (q_idx < s_q_idx) {
@@ -846,12 +846,12 @@ static int tc_dump_qdisc(struct sk_buff *skb, struct netlink_callback *cb)
846 } 846 }
847 if (tc_fill_qdisc(skb, q, q->parent, NETLINK_CB(cb->skb).pid, 847 if (tc_fill_qdisc(skb, q, q->parent, NETLINK_CB(cb->skb).pid,
848 cb->nlh->nlmsg_seq, NLM_F_MULTI, RTM_NEWQDISC) <= 0) { 848 cb->nlh->nlmsg_seq, NLM_F_MULTI, RTM_NEWQDISC) <= 0) {
849 read_unlock_bh(&qdisc_tree_lock); 849 read_unlock(&qdisc_tree_lock);
850 goto done; 850 goto done;
851 } 851 }
852 q_idx++; 852 q_idx++;
853 } 853 }
854 read_unlock_bh(&qdisc_tree_lock); 854 read_unlock(&qdisc_tree_lock);
855 } 855 }
856 856
857done: 857done:
@@ -1074,7 +1074,7 @@ static int tc_dump_tclass(struct sk_buff *skb, struct netlink_callback *cb)
1074 s_t = cb->args[0]; 1074 s_t = cb->args[0];
1075 t = 0; 1075 t = 0;
1076 1076
1077 read_lock_bh(&qdisc_tree_lock); 1077 read_lock(&qdisc_tree_lock);
1078 list_for_each_entry(q, &dev->qdisc_list, list) { 1078 list_for_each_entry(q, &dev->qdisc_list, list) {
1079 if (t < s_t || !q->ops->cl_ops || 1079 if (t < s_t || !q->ops->cl_ops ||
1080 (tcm->tcm_parent && 1080 (tcm->tcm_parent &&
@@ -1096,7 +1096,7 @@ static int tc_dump_tclass(struct sk_buff *skb, struct netlink_callback *cb)
1096 break; 1096 break;
1097 t++; 1097 t++;
1098 } 1098 }
1099 read_unlock_bh(&qdisc_tree_lock); 1099 read_unlock(&qdisc_tree_lock);
1100 1100
1101 cb->args[0] = t; 1101 cb->args[0] = t;
1102 1102
diff --git a/net/sched/sch_generic.c b/net/sched/sch_generic.c
index 6f9151899795..88c6a99ce53c 100644
--- a/net/sched/sch_generic.c
+++ b/net/sched/sch_generic.c
@@ -45,11 +45,10 @@
45 The idea is the following: 45 The idea is the following:
46 - enqueue, dequeue are serialized via top level device 46 - enqueue, dequeue are serialized via top level device
47 spinlock dev->queue_lock. 47 spinlock dev->queue_lock.
48 - tree walking is protected by read_lock_bh(qdisc_tree_lock) 48 - tree walking is protected by read_lock(qdisc_tree_lock)
49 and this lock is used only in process context. 49 and this lock is used only in process context.
50 - updates to tree are made under rtnl semaphore or 50 - updates to tree are made only under rtnl semaphore,
51 from softirq context (__qdisc_destroy rcu-callback) 51 hence this lock may be made without local bh disabling.
52 hence this lock needs local bh disabling.
53 52
54 qdisc_tree_lock must be grabbed BEFORE dev->queue_lock! 53 qdisc_tree_lock must be grabbed BEFORE dev->queue_lock!
55 */ 54 */
@@ -57,14 +56,14 @@ DEFINE_RWLOCK(qdisc_tree_lock);
57 56
58void qdisc_lock_tree(struct net_device *dev) 57void qdisc_lock_tree(struct net_device *dev)
59{ 58{
60 write_lock_bh(&qdisc_tree_lock); 59 write_lock(&qdisc_tree_lock);
61 spin_lock_bh(&dev->queue_lock); 60 spin_lock_bh(&dev->queue_lock);
62} 61}
63 62
64void qdisc_unlock_tree(struct net_device *dev) 63void qdisc_unlock_tree(struct net_device *dev)
65{ 64{
66 spin_unlock_bh(&dev->queue_lock); 65 spin_unlock_bh(&dev->queue_lock);
67 write_unlock_bh(&qdisc_tree_lock); 66 write_unlock(&qdisc_tree_lock);
68} 67}
69 68
70/* 69/*
@@ -483,20 +482,6 @@ void qdisc_reset(struct Qdisc *qdisc)
483static void __qdisc_destroy(struct rcu_head *head) 482static void __qdisc_destroy(struct rcu_head *head)
484{ 483{
485 struct Qdisc *qdisc = container_of(head, struct Qdisc, q_rcu); 484 struct Qdisc *qdisc = container_of(head, struct Qdisc, q_rcu);
486 struct Qdisc_ops *ops = qdisc->ops;
487
488#ifdef CONFIG_NET_ESTIMATOR
489 gen_kill_estimator(&qdisc->bstats, &qdisc->rate_est);
490#endif
491 write_lock(&qdisc_tree_lock);
492 if (ops->reset)
493 ops->reset(qdisc);
494 if (ops->destroy)
495 ops->destroy(qdisc);
496 write_unlock(&qdisc_tree_lock);
497 module_put(ops->owner);
498
499 dev_put(qdisc->dev);
500 kfree((char *) qdisc - qdisc->padded); 485 kfree((char *) qdisc - qdisc->padded);
501} 486}
502 487
@@ -504,32 +489,23 @@ static void __qdisc_destroy(struct rcu_head *head)
504 489
505void qdisc_destroy(struct Qdisc *qdisc) 490void qdisc_destroy(struct Qdisc *qdisc)
506{ 491{
507 struct list_head cql = LIST_HEAD_INIT(cql); 492 struct Qdisc_ops *ops = qdisc->ops;
508 struct Qdisc *cq, *q, *n;
509 493
510 if (qdisc->flags & TCQ_F_BUILTIN || 494 if (qdisc->flags & TCQ_F_BUILTIN ||
511 !atomic_dec_and_test(&qdisc->refcnt)) 495 !atomic_dec_and_test(&qdisc->refcnt))
512 return; 496 return;
513 497
514 if (!list_empty(&qdisc->list)) { 498 list_del(&qdisc->list);
515 if (qdisc->ops->cl_ops == NULL) 499#ifdef CONFIG_NET_ESTIMATOR
516 list_del(&qdisc->list); 500 gen_kill_estimator(&qdisc->bstats, &qdisc->rate_est);
517 else 501#endif
518 list_move(&qdisc->list, &cql); 502 if (ops->reset)
519 } 503 ops->reset(qdisc);
520 504 if (ops->destroy)
521 /* unlink inner qdiscs from dev->qdisc_list immediately */ 505 ops->destroy(qdisc);
522 list_for_each_entry(cq, &cql, list)
523 list_for_each_entry_safe(q, n, &qdisc->dev->qdisc_list, list)
524 if (TC_H_MAJ(q->parent) == TC_H_MAJ(cq->handle)) {
525 if (q->ops->cl_ops == NULL)
526 list_del_init(&q->list);
527 else
528 list_move_tail(&q->list, &cql);
529 }
530 list_for_each_entry_safe(cq, n, &cql, list)
531 list_del_init(&cq->list);
532 506
507 module_put(ops->owner);
508 dev_put(qdisc->dev);
533 call_rcu(&qdisc->q_rcu, __qdisc_destroy); 509 call_rcu(&qdisc->q_rcu, __qdisc_destroy);
534} 510}
535 511
@@ -549,15 +525,15 @@ void dev_activate(struct net_device *dev)
549 printk(KERN_INFO "%s: activation failed\n", dev->name); 525 printk(KERN_INFO "%s: activation failed\n", dev->name);
550 return; 526 return;
551 } 527 }
552 write_lock_bh(&qdisc_tree_lock); 528 write_lock(&qdisc_tree_lock);
553 list_add_tail(&qdisc->list, &dev->qdisc_list); 529 list_add_tail(&qdisc->list, &dev->qdisc_list);
554 write_unlock_bh(&qdisc_tree_lock); 530 write_unlock(&qdisc_tree_lock);
555 } else { 531 } else {
556 qdisc = &noqueue_qdisc; 532 qdisc = &noqueue_qdisc;
557 } 533 }
558 write_lock_bh(&qdisc_tree_lock); 534 write_lock(&qdisc_tree_lock);
559 dev->qdisc_sleeping = qdisc; 535 dev->qdisc_sleeping = qdisc;
560 write_unlock_bh(&qdisc_tree_lock); 536 write_unlock(&qdisc_tree_lock);
561 } 537 }
562 538
563 if (!netif_carrier_ok(dev)) 539 if (!netif_carrier_ok(dev))
diff --git a/net/sched/sch_htb.c b/net/sched/sch_htb.c
index bb3ddd4784b1..6c058e3660c0 100644
--- a/net/sched/sch_htb.c
+++ b/net/sched/sch_htb.c
@@ -391,7 +391,7 @@ static inline void htb_add_class_to_row(struct htb_sched *q,
391/* If this triggers, it is a bug in this code, but it need not be fatal */ 391/* If this triggers, it is a bug in this code, but it need not be fatal */
392static void htb_safe_rb_erase(struct rb_node *rb, struct rb_root *root) 392static void htb_safe_rb_erase(struct rb_node *rb, struct rb_root *root)
393{ 393{
394 if (RB_EMPTY_NODE(rb)) { 394 if (!RB_EMPTY_NODE(rb)) {
395 WARN_ON(1); 395 WARN_ON(1);
396 } else { 396 } else {
397 rb_erase(rb, root); 397 rb_erase(rb, root);
diff --git a/net/sunrpc/auth.c b/net/sunrpc/auth.c
index 55163af3dcaf..993ff1a5d945 100644
--- a/net/sunrpc/auth.c
+++ b/net/sunrpc/auth.c
@@ -331,8 +331,8 @@ rpcauth_unbindcred(struct rpc_task *task)
331 task->tk_msg.rpc_cred = NULL; 331 task->tk_msg.rpc_cred = NULL;
332} 332}
333 333
334u32 * 334__be32 *
335rpcauth_marshcred(struct rpc_task *task, u32 *p) 335rpcauth_marshcred(struct rpc_task *task, __be32 *p)
336{ 336{
337 struct rpc_cred *cred = task->tk_msg.rpc_cred; 337 struct rpc_cred *cred = task->tk_msg.rpc_cred;
338 338
@@ -342,8 +342,8 @@ rpcauth_marshcred(struct rpc_task *task, u32 *p)
342 return cred->cr_ops->crmarshal(task, p); 342 return cred->cr_ops->crmarshal(task, p);
343} 343}
344 344
345u32 * 345__be32 *
346rpcauth_checkverf(struct rpc_task *task, u32 *p) 346rpcauth_checkverf(struct rpc_task *task, __be32 *p)
347{ 347{
348 struct rpc_cred *cred = task->tk_msg.rpc_cred; 348 struct rpc_cred *cred = task->tk_msg.rpc_cred;
349 349
@@ -355,7 +355,7 @@ rpcauth_checkverf(struct rpc_task *task, u32 *p)
355 355
356int 356int
357rpcauth_wrap_req(struct rpc_task *task, kxdrproc_t encode, void *rqstp, 357rpcauth_wrap_req(struct rpc_task *task, kxdrproc_t encode, void *rqstp,
358 u32 *data, void *obj) 358 __be32 *data, void *obj)
359{ 359{
360 struct rpc_cred *cred = task->tk_msg.rpc_cred; 360 struct rpc_cred *cred = task->tk_msg.rpc_cred;
361 361
@@ -369,7 +369,7 @@ rpcauth_wrap_req(struct rpc_task *task, kxdrproc_t encode, void *rqstp,
369 369
370int 370int
371rpcauth_unwrap_resp(struct rpc_task *task, kxdrproc_t decode, void *rqstp, 371rpcauth_unwrap_resp(struct rpc_task *task, kxdrproc_t decode, void *rqstp,
372 u32 *data, void *obj) 372 __be32 *data, void *obj)
373{ 373{
374 struct rpc_cred *cred = task->tk_msg.rpc_cred; 374 struct rpc_cred *cred = task->tk_msg.rpc_cred;
375 375
diff --git a/net/sunrpc/auth_gss/auth_gss.c b/net/sunrpc/auth_gss/auth_gss.c
index 6eed3e166ba3..a6ed2d22a6e6 100644
--- a/net/sunrpc/auth_gss/auth_gss.c
+++ b/net/sunrpc/auth_gss/auth_gss.c
@@ -826,14 +826,14 @@ out:
826* Marshal credentials. 826* Marshal credentials.
827* Maybe we should keep a cached credential for performance reasons. 827* Maybe we should keep a cached credential for performance reasons.
828*/ 828*/
829static u32 * 829static __be32 *
830gss_marshal(struct rpc_task *task, u32 *p) 830gss_marshal(struct rpc_task *task, __be32 *p)
831{ 831{
832 struct rpc_cred *cred = task->tk_msg.rpc_cred; 832 struct rpc_cred *cred = task->tk_msg.rpc_cred;
833 struct gss_cred *gss_cred = container_of(cred, struct gss_cred, 833 struct gss_cred *gss_cred = container_of(cred, struct gss_cred,
834 gc_base); 834 gc_base);
835 struct gss_cl_ctx *ctx = gss_cred_get_ctx(cred); 835 struct gss_cl_ctx *ctx = gss_cred_get_ctx(cred);
836 u32 *cred_len; 836 __be32 *cred_len;
837 struct rpc_rqst *req = task->tk_rqstp; 837 struct rpc_rqst *req = task->tk_rqstp;
838 u32 maj_stat = 0; 838 u32 maj_stat = 0;
839 struct xdr_netobj mic; 839 struct xdr_netobj mic;
@@ -894,12 +894,12 @@ gss_refresh(struct rpc_task *task)
894 return 0; 894 return 0;
895} 895}
896 896
897static u32 * 897static __be32 *
898gss_validate(struct rpc_task *task, u32 *p) 898gss_validate(struct rpc_task *task, __be32 *p)
899{ 899{
900 struct rpc_cred *cred = task->tk_msg.rpc_cred; 900 struct rpc_cred *cred = task->tk_msg.rpc_cred;
901 struct gss_cl_ctx *ctx = gss_cred_get_ctx(cred); 901 struct gss_cl_ctx *ctx = gss_cred_get_ctx(cred);
902 u32 seq; 902 __be32 seq;
903 struct kvec iov; 903 struct kvec iov;
904 struct xdr_buf verf_buf; 904 struct xdr_buf verf_buf;
905 struct xdr_netobj mic; 905 struct xdr_netobj mic;
@@ -940,13 +940,14 @@ out_bad:
940 940
941static inline int 941static inline int
942gss_wrap_req_integ(struct rpc_cred *cred, struct gss_cl_ctx *ctx, 942gss_wrap_req_integ(struct rpc_cred *cred, struct gss_cl_ctx *ctx,
943 kxdrproc_t encode, struct rpc_rqst *rqstp, u32 *p, void *obj) 943 kxdrproc_t encode, struct rpc_rqst *rqstp, __be32 *p, void *obj)
944{ 944{
945 struct xdr_buf *snd_buf = &rqstp->rq_snd_buf; 945 struct xdr_buf *snd_buf = &rqstp->rq_snd_buf;
946 struct xdr_buf integ_buf; 946 struct xdr_buf integ_buf;
947 u32 *integ_len = NULL; 947 __be32 *integ_len = NULL;
948 struct xdr_netobj mic; 948 struct xdr_netobj mic;
949 u32 offset, *q; 949 u32 offset;
950 __be32 *q;
950 struct kvec *iov; 951 struct kvec *iov;
951 u32 maj_stat = 0; 952 u32 maj_stat = 0;
952 int status = -EIO; 953 int status = -EIO;
@@ -1032,13 +1033,13 @@ out:
1032 1033
1033static inline int 1034static inline int
1034gss_wrap_req_priv(struct rpc_cred *cred, struct gss_cl_ctx *ctx, 1035gss_wrap_req_priv(struct rpc_cred *cred, struct gss_cl_ctx *ctx,
1035 kxdrproc_t encode, struct rpc_rqst *rqstp, u32 *p, void *obj) 1036 kxdrproc_t encode, struct rpc_rqst *rqstp, __be32 *p, void *obj)
1036{ 1037{
1037 struct xdr_buf *snd_buf = &rqstp->rq_snd_buf; 1038 struct xdr_buf *snd_buf = &rqstp->rq_snd_buf;
1038 u32 offset; 1039 u32 offset;
1039 u32 maj_stat; 1040 u32 maj_stat;
1040 int status; 1041 int status;
1041 u32 *opaque_len; 1042 __be32 *opaque_len;
1042 struct page **inpages; 1043 struct page **inpages;
1043 int first; 1044 int first;
1044 int pad; 1045 int pad;
@@ -1095,7 +1096,7 @@ gss_wrap_req_priv(struct rpc_cred *cred, struct gss_cl_ctx *ctx,
1095 1096
1096static int 1097static int
1097gss_wrap_req(struct rpc_task *task, 1098gss_wrap_req(struct rpc_task *task,
1098 kxdrproc_t encode, void *rqstp, u32 *p, void *obj) 1099 kxdrproc_t encode, void *rqstp, __be32 *p, void *obj)
1099{ 1100{
1100 struct rpc_cred *cred = task->tk_msg.rpc_cred; 1101 struct rpc_cred *cred = task->tk_msg.rpc_cred;
1101 struct gss_cred *gss_cred = container_of(cred, struct gss_cred, 1102 struct gss_cred *gss_cred = container_of(cred, struct gss_cred,
@@ -1132,7 +1133,7 @@ out:
1132 1133
1133static inline int 1134static inline int
1134gss_unwrap_resp_integ(struct rpc_cred *cred, struct gss_cl_ctx *ctx, 1135gss_unwrap_resp_integ(struct rpc_cred *cred, struct gss_cl_ctx *ctx,
1135 struct rpc_rqst *rqstp, u32 **p) 1136 struct rpc_rqst *rqstp, __be32 **p)
1136{ 1137{
1137 struct xdr_buf *rcv_buf = &rqstp->rq_rcv_buf; 1138 struct xdr_buf *rcv_buf = &rqstp->rq_rcv_buf;
1138 struct xdr_buf integ_buf; 1139 struct xdr_buf integ_buf;
@@ -1169,7 +1170,7 @@ gss_unwrap_resp_integ(struct rpc_cred *cred, struct gss_cl_ctx *ctx,
1169 1170
1170static inline int 1171static inline int
1171gss_unwrap_resp_priv(struct rpc_cred *cred, struct gss_cl_ctx *ctx, 1172gss_unwrap_resp_priv(struct rpc_cred *cred, struct gss_cl_ctx *ctx,
1172 struct rpc_rqst *rqstp, u32 **p) 1173 struct rpc_rqst *rqstp, __be32 **p)
1173{ 1174{
1174 struct xdr_buf *rcv_buf = &rqstp->rq_rcv_buf; 1175 struct xdr_buf *rcv_buf = &rqstp->rq_rcv_buf;
1175 u32 offset; 1176 u32 offset;
@@ -1198,13 +1199,13 @@ gss_unwrap_resp_priv(struct rpc_cred *cred, struct gss_cl_ctx *ctx,
1198 1199
1199static int 1200static int
1200gss_unwrap_resp(struct rpc_task *task, 1201gss_unwrap_resp(struct rpc_task *task,
1201 kxdrproc_t decode, void *rqstp, u32 *p, void *obj) 1202 kxdrproc_t decode, void *rqstp, __be32 *p, void *obj)
1202{ 1203{
1203 struct rpc_cred *cred = task->tk_msg.rpc_cred; 1204 struct rpc_cred *cred = task->tk_msg.rpc_cred;
1204 struct gss_cred *gss_cred = container_of(cred, struct gss_cred, 1205 struct gss_cred *gss_cred = container_of(cred, struct gss_cred,
1205 gc_base); 1206 gc_base);
1206 struct gss_cl_ctx *ctx = gss_cred_get_ctx(cred); 1207 struct gss_cl_ctx *ctx = gss_cred_get_ctx(cred);
1207 u32 *savedp = p; 1208 __be32 *savedp = p;
1208 struct kvec *head = ((struct rpc_rqst *)rqstp)->rq_rcv_buf.head; 1209 struct kvec *head = ((struct rpc_rqst *)rqstp)->rq_rcv_buf.head;
1209 int savedlen = head->iov_len; 1210 int savedlen = head->iov_len;
1210 int status = -EIO; 1211 int status = -EIO;
diff --git a/net/sunrpc/auth_gss/gss_krb5_seal.c b/net/sunrpc/auth_gss/gss_krb5_seal.c
index 2f312164d6d5..08601ee4cd73 100644
--- a/net/sunrpc/auth_gss/gss_krb5_seal.c
+++ b/net/sunrpc/auth_gss/gss_krb5_seal.c
@@ -115,7 +115,7 @@ gss_get_mic_kerberos(struct gss_ctx *gss_ctx, struct xdr_buf *text,
115 krb5_hdr = ptr - 2; 115 krb5_hdr = ptr - 2;
116 msg_start = krb5_hdr + 24; 116 msg_start = krb5_hdr + 24;
117 117
118 *(u16 *)(krb5_hdr + 2) = htons(ctx->signalg); 118 *(__be16 *)(krb5_hdr + 2) = htons(ctx->signalg);
119 memset(krb5_hdr + 4, 0xff, 4); 119 memset(krb5_hdr + 4, 0xff, 4);
120 120
121 if (make_checksum(checksum_type, krb5_hdr, 8, text, 0, &md5cksum)) 121 if (make_checksum(checksum_type, krb5_hdr, 8, text, 0, &md5cksum))
diff --git a/net/sunrpc/auth_gss/gss_krb5_wrap.c b/net/sunrpc/auth_gss/gss_krb5_wrap.c
index f179415d0c38..cc45c1605f80 100644
--- a/net/sunrpc/auth_gss/gss_krb5_wrap.c
+++ b/net/sunrpc/auth_gss/gss_krb5_wrap.c
@@ -177,9 +177,9 @@ gss_wrap_kerberos(struct gss_ctx *ctx, int offset,
177 msg_start = krb5_hdr + 24; 177 msg_start = krb5_hdr + 24;
178 /* XXXJBF: */ BUG_ON(buf->head[0].iov_base + offset + headlen != msg_start + blocksize); 178 /* XXXJBF: */ BUG_ON(buf->head[0].iov_base + offset + headlen != msg_start + blocksize);
179 179
180 *(u16 *)(krb5_hdr + 2) = htons(kctx->signalg); 180 *(__be16 *)(krb5_hdr + 2) = htons(kctx->signalg);
181 memset(krb5_hdr + 4, 0xff, 4); 181 memset(krb5_hdr + 4, 0xff, 4);
182 *(u16 *)(krb5_hdr + 4) = htons(kctx->sealalg); 182 *(__be16 *)(krb5_hdr + 4) = htons(kctx->sealalg);
183 183
184 make_confounder(msg_start, blocksize); 184 make_confounder(msg_start, blocksize);
185 185
diff --git a/net/sunrpc/auth_gss/svcauth_gss.c b/net/sunrpc/auth_gss/svcauth_gss.c
index 94217ec9e2dd..638c0b576203 100644
--- a/net/sunrpc/auth_gss/svcauth_gss.c
+++ b/net/sunrpc/auth_gss/svcauth_gss.c
@@ -607,7 +607,7 @@ svc_safe_getnetobj(struct kvec *argv, struct xdr_netobj *o)
607 607
608 if (argv->iov_len < 4) 608 if (argv->iov_len < 4)
609 return -1; 609 return -1;
610 o->len = ntohl(svc_getu32(argv)); 610 o->len = svc_getnl(argv);
611 l = round_up_to_quad(o->len); 611 l = round_up_to_quad(o->len);
612 if (argv->iov_len < l) 612 if (argv->iov_len < l)
613 return -1; 613 return -1;
@@ -620,17 +620,17 @@ svc_safe_getnetobj(struct kvec *argv, struct xdr_netobj *o)
620static inline int 620static inline int
621svc_safe_putnetobj(struct kvec *resv, struct xdr_netobj *o) 621svc_safe_putnetobj(struct kvec *resv, struct xdr_netobj *o)
622{ 622{
623 u32 *p; 623 u8 *p;
624 624
625 if (resv->iov_len + 4 > PAGE_SIZE) 625 if (resv->iov_len + 4 > PAGE_SIZE)
626 return -1; 626 return -1;
627 svc_putu32(resv, htonl(o->len)); 627 svc_putnl(resv, o->len);
628 p = resv->iov_base + resv->iov_len; 628 p = resv->iov_base + resv->iov_len;
629 resv->iov_len += round_up_to_quad(o->len); 629 resv->iov_len += round_up_to_quad(o->len);
630 if (resv->iov_len > PAGE_SIZE) 630 if (resv->iov_len > PAGE_SIZE)
631 return -1; 631 return -1;
632 memcpy(p, o->data, o->len); 632 memcpy(p, o->data, o->len);
633 memset((u8 *)p + o->len, 0, round_up_to_quad(o->len) - o->len); 633 memset(p + o->len, 0, round_up_to_quad(o->len) - o->len);
634 return 0; 634 return 0;
635} 635}
636 636
@@ -640,7 +640,7 @@ svc_safe_putnetobj(struct kvec *resv, struct xdr_netobj *o)
640 */ 640 */
641static int 641static int
642gss_verify_header(struct svc_rqst *rqstp, struct rsc *rsci, 642gss_verify_header(struct svc_rqst *rqstp, struct rsc *rsci,
643 u32 *rpcstart, struct rpc_gss_wire_cred *gc, u32 *authp) 643 __be32 *rpcstart, struct rpc_gss_wire_cred *gc, __be32 *authp)
644{ 644{
645 struct gss_ctx *ctx_id = rsci->mechctx; 645 struct gss_ctx *ctx_id = rsci->mechctx;
646 struct xdr_buf rpchdr; 646 struct xdr_buf rpchdr;
@@ -657,7 +657,7 @@ gss_verify_header(struct svc_rqst *rqstp, struct rsc *rsci,
657 *authp = rpc_autherr_badverf; 657 *authp = rpc_autherr_badverf;
658 if (argv->iov_len < 4) 658 if (argv->iov_len < 4)
659 return SVC_DENIED; 659 return SVC_DENIED;
660 flavor = ntohl(svc_getu32(argv)); 660 flavor = svc_getnl(argv);
661 if (flavor != RPC_AUTH_GSS) 661 if (flavor != RPC_AUTH_GSS)
662 return SVC_DENIED; 662 return SVC_DENIED;
663 if (svc_safe_getnetobj(argv, &checksum)) 663 if (svc_safe_getnetobj(argv, &checksum))
@@ -687,9 +687,9 @@ gss_verify_header(struct svc_rqst *rqstp, struct rsc *rsci,
687static int 687static int
688gss_write_null_verf(struct svc_rqst *rqstp) 688gss_write_null_verf(struct svc_rqst *rqstp)
689{ 689{
690 u32 *p; 690 __be32 *p;
691 691
692 svc_putu32(rqstp->rq_res.head, htonl(RPC_AUTH_NULL)); 692 svc_putnl(rqstp->rq_res.head, RPC_AUTH_NULL);
693 p = rqstp->rq_res.head->iov_base + rqstp->rq_res.head->iov_len; 693 p = rqstp->rq_res.head->iov_base + rqstp->rq_res.head->iov_len;
694 /* don't really need to check if head->iov_len > PAGE_SIZE ... */ 694 /* don't really need to check if head->iov_len > PAGE_SIZE ... */
695 *p++ = 0; 695 *p++ = 0;
@@ -701,14 +701,14 @@ gss_write_null_verf(struct svc_rqst *rqstp)
701static int 701static int
702gss_write_verf(struct svc_rqst *rqstp, struct gss_ctx *ctx_id, u32 seq) 702gss_write_verf(struct svc_rqst *rqstp, struct gss_ctx *ctx_id, u32 seq)
703{ 703{
704 u32 xdr_seq; 704 __be32 xdr_seq;
705 u32 maj_stat; 705 u32 maj_stat;
706 struct xdr_buf verf_data; 706 struct xdr_buf verf_data;
707 struct xdr_netobj mic; 707 struct xdr_netobj mic;
708 u32 *p; 708 __be32 *p;
709 struct kvec iov; 709 struct kvec iov;
710 710
711 svc_putu32(rqstp->rq_res.head, htonl(RPC_AUTH_GSS)); 711 svc_putnl(rqstp->rq_res.head, RPC_AUTH_GSS);
712 xdr_seq = htonl(seq); 712 xdr_seq = htonl(seq);
713 713
714 iov.iov_base = &xdr_seq; 714 iov.iov_base = &xdr_seq;
@@ -782,7 +782,7 @@ EXPORT_SYMBOL(svcauth_gss_register_pseudoflavor);
782static inline int 782static inline int
783read_u32_from_xdr_buf(struct xdr_buf *buf, int base, u32 *obj) 783read_u32_from_xdr_buf(struct xdr_buf *buf, int base, u32 *obj)
784{ 784{
785 u32 raw; 785 __be32 raw;
786 int status; 786 int status;
787 787
788 status = read_bytes_from_xdr_buf(buf, base, &raw, sizeof(*obj)); 788 status = read_bytes_from_xdr_buf(buf, base, &raw, sizeof(*obj));
@@ -805,7 +805,7 @@ unwrap_integ_data(struct xdr_buf *buf, u32 seq, struct gss_ctx *ctx)
805 struct xdr_netobj mic; 805 struct xdr_netobj mic;
806 struct xdr_buf integ_buf; 806 struct xdr_buf integ_buf;
807 807
808 integ_len = ntohl(svc_getu32(&buf->head[0])); 808 integ_len = svc_getnl(&buf->head[0]);
809 if (integ_len & 3) 809 if (integ_len & 3)
810 goto out; 810 goto out;
811 if (integ_len > buf->len) 811 if (integ_len > buf->len)
@@ -825,7 +825,7 @@ unwrap_integ_data(struct xdr_buf *buf, u32 seq, struct gss_ctx *ctx)
825 maj_stat = gss_verify_mic(ctx, &integ_buf, &mic); 825 maj_stat = gss_verify_mic(ctx, &integ_buf, &mic);
826 if (maj_stat != GSS_S_COMPLETE) 826 if (maj_stat != GSS_S_COMPLETE)
827 goto out; 827 goto out;
828 if (ntohl(svc_getu32(&buf->head[0])) != seq) 828 if (svc_getnl(&buf->head[0]) != seq)
829 goto out; 829 goto out;
830 stat = 0; 830 stat = 0;
831out: 831out:
@@ -857,7 +857,7 @@ unwrap_priv_data(struct svc_rqst *rqstp, struct xdr_buf *buf, u32 seq, struct gs
857 857
858 rqstp->rq_sendfile_ok = 0; 858 rqstp->rq_sendfile_ok = 0;
859 859
860 priv_len = ntohl(svc_getu32(&buf->head[0])); 860 priv_len = svc_getnl(&buf->head[0]);
861 if (rqstp->rq_deferred) { 861 if (rqstp->rq_deferred) {
862 /* Already decrypted last time through! The sequence number 862 /* Already decrypted last time through! The sequence number
863 * check at out_seq is unnecessary but harmless: */ 863 * check at out_seq is unnecessary but harmless: */
@@ -895,7 +895,7 @@ unwrap_priv_data(struct svc_rqst *rqstp, struct xdr_buf *buf, u32 seq, struct gs
895 if (maj_stat != GSS_S_COMPLETE) 895 if (maj_stat != GSS_S_COMPLETE)
896 return -EINVAL; 896 return -EINVAL;
897out_seq: 897out_seq:
898 if (ntohl(svc_getu32(&buf->head[0])) != seq) 898 if (svc_getnl(&buf->head[0]) != seq)
899 return -EINVAL; 899 return -EINVAL;
900 return 0; 900 return 0;
901} 901}
@@ -905,7 +905,7 @@ struct gss_svc_data {
905 struct rpc_gss_wire_cred clcred; 905 struct rpc_gss_wire_cred clcred;
906 /* pointer to the beginning of the procedure-specific results, 906 /* pointer to the beginning of the procedure-specific results,
907 * which may be encrypted/checksummed in svcauth_gss_release: */ 907 * which may be encrypted/checksummed in svcauth_gss_release: */
908 u32 *body_start; 908 __be32 *body_start;
909 struct rsc *rsci; 909 struct rsc *rsci;
910}; 910};
911 911
@@ -946,7 +946,7 @@ gss_write_init_verf(struct svc_rqst *rqstp, struct rsi *rsip)
946 * response here and return SVC_COMPLETE. 946 * response here and return SVC_COMPLETE.
947 */ 947 */
948static int 948static int
949svcauth_gss_accept(struct svc_rqst *rqstp, u32 *authp) 949svcauth_gss_accept(struct svc_rqst *rqstp, __be32 *authp)
950{ 950{
951 struct kvec *argv = &rqstp->rq_arg.head[0]; 951 struct kvec *argv = &rqstp->rq_arg.head[0];
952 struct kvec *resv = &rqstp->rq_res.head[0]; 952 struct kvec *resv = &rqstp->rq_res.head[0];
@@ -956,8 +956,8 @@ svcauth_gss_accept(struct svc_rqst *rqstp, u32 *authp)
956 struct rpc_gss_wire_cred *gc; 956 struct rpc_gss_wire_cred *gc;
957 struct rsc *rsci = NULL; 957 struct rsc *rsci = NULL;
958 struct rsi *rsip, rsikey; 958 struct rsi *rsip, rsikey;
959 u32 *rpcstart; 959 __be32 *rpcstart;
960 u32 *reject_stat = resv->iov_base + resv->iov_len; 960 __be32 *reject_stat = resv->iov_base + resv->iov_len;
961 int ret; 961 int ret;
962 962
963 dprintk("RPC: svcauth_gss: argv->iov_len = %zd\n",argv->iov_len); 963 dprintk("RPC: svcauth_gss: argv->iov_len = %zd\n",argv->iov_len);
@@ -985,12 +985,12 @@ svcauth_gss_accept(struct svc_rqst *rqstp, u32 *authp)
985 985
986 if (argv->iov_len < 5 * 4) 986 if (argv->iov_len < 5 * 4)
987 goto auth_err; 987 goto auth_err;
988 crlen = ntohl(svc_getu32(argv)); 988 crlen = svc_getnl(argv);
989 if (ntohl(svc_getu32(argv)) != RPC_GSS_VERSION) 989 if (svc_getnl(argv) != RPC_GSS_VERSION)
990 goto auth_err; 990 goto auth_err;
991 gc->gc_proc = ntohl(svc_getu32(argv)); 991 gc->gc_proc = svc_getnl(argv);
992 gc->gc_seq = ntohl(svc_getu32(argv)); 992 gc->gc_seq = svc_getnl(argv);
993 gc->gc_svc = ntohl(svc_getu32(argv)); 993 gc->gc_svc = svc_getnl(argv);
994 if (svc_safe_getnetobj(argv, &gc->gc_ctx)) 994 if (svc_safe_getnetobj(argv, &gc->gc_ctx))
995 goto auth_err; 995 goto auth_err;
996 if (crlen != round_up_to_quad(gc->gc_ctx.len) + 5 * 4) 996 if (crlen != round_up_to_quad(gc->gc_ctx.len) + 5 * 4)
@@ -1016,9 +1016,9 @@ svcauth_gss_accept(struct svc_rqst *rqstp, u32 *authp)
1016 case RPC_GSS_PROC_CONTINUE_INIT: 1016 case RPC_GSS_PROC_CONTINUE_INIT:
1017 if (argv->iov_len < 2 * 4) 1017 if (argv->iov_len < 2 * 4)
1018 goto auth_err; 1018 goto auth_err;
1019 if (ntohl(svc_getu32(argv)) != RPC_AUTH_NULL) 1019 if (svc_getnl(argv) != RPC_AUTH_NULL)
1020 goto auth_err; 1020 goto auth_err;
1021 if (ntohl(svc_getu32(argv)) != 0) 1021 if (svc_getnl(argv) != 0)
1022 goto auth_err; 1022 goto auth_err;
1023 break; 1023 break;
1024 case RPC_GSS_PROC_DATA: 1024 case RPC_GSS_PROC_DATA:
@@ -1076,14 +1076,14 @@ svcauth_gss_accept(struct svc_rqst *rqstp, u32 *authp)
1076 goto drop; 1076 goto drop;
1077 if (resv->iov_len + 4 > PAGE_SIZE) 1077 if (resv->iov_len + 4 > PAGE_SIZE)
1078 goto drop; 1078 goto drop;
1079 svc_putu32(resv, rpc_success); 1079 svc_putnl(resv, RPC_SUCCESS);
1080 if (svc_safe_putnetobj(resv, &rsip->out_handle)) 1080 if (svc_safe_putnetobj(resv, &rsip->out_handle))
1081 goto drop; 1081 goto drop;
1082 if (resv->iov_len + 3 * 4 > PAGE_SIZE) 1082 if (resv->iov_len + 3 * 4 > PAGE_SIZE)
1083 goto drop; 1083 goto drop;
1084 svc_putu32(resv, htonl(rsip->major_status)); 1084 svc_putnl(resv, rsip->major_status);
1085 svc_putu32(resv, htonl(rsip->minor_status)); 1085 svc_putnl(resv, rsip->minor_status);
1086 svc_putu32(resv, htonl(GSS_SEQ_WIN)); 1086 svc_putnl(resv, GSS_SEQ_WIN);
1087 if (svc_safe_putnetobj(resv, &rsip->out_token)) 1087 if (svc_safe_putnetobj(resv, &rsip->out_token))
1088 goto drop; 1088 goto drop;
1089 rqstp->rq_client = NULL; 1089 rqstp->rq_client = NULL;
@@ -1093,7 +1093,7 @@ svcauth_gss_accept(struct svc_rqst *rqstp, u32 *authp)
1093 set_bit(CACHE_NEGATIVE, &rsci->h.flags); 1093 set_bit(CACHE_NEGATIVE, &rsci->h.flags);
1094 if (resv->iov_len + 4 > PAGE_SIZE) 1094 if (resv->iov_len + 4 > PAGE_SIZE)
1095 goto drop; 1095 goto drop;
1096 svc_putu32(resv, rpc_success); 1096 svc_putnl(resv, RPC_SUCCESS);
1097 goto complete; 1097 goto complete;
1098 case RPC_GSS_PROC_DATA: 1098 case RPC_GSS_PROC_DATA:
1099 *authp = rpcsec_gsserr_ctxproblem; 1099 *authp = rpcsec_gsserr_ctxproblem;
@@ -1111,8 +1111,8 @@ svcauth_gss_accept(struct svc_rqst *rqstp, u32 *authp)
1111 goto auth_err; 1111 goto auth_err;
1112 /* placeholders for length and seq. number: */ 1112 /* placeholders for length and seq. number: */
1113 svcdata->body_start = resv->iov_base + resv->iov_len; 1113 svcdata->body_start = resv->iov_base + resv->iov_len;
1114 svc_putu32(resv, 0); 1114 svc_putnl(resv, 0);
1115 svc_putu32(resv, 0); 1115 svc_putnl(resv, 0);
1116 break; 1116 break;
1117 case RPC_GSS_SVC_PRIVACY: 1117 case RPC_GSS_SVC_PRIVACY:
1118 if (unwrap_priv_data(rqstp, &rqstp->rq_arg, 1118 if (unwrap_priv_data(rqstp, &rqstp->rq_arg,
@@ -1120,8 +1120,8 @@ svcauth_gss_accept(struct svc_rqst *rqstp, u32 *authp)
1120 goto auth_err; 1120 goto auth_err;
1121 /* placeholders for length and seq. number: */ 1121 /* placeholders for length and seq. number: */
1122 svcdata->body_start = resv->iov_base + resv->iov_len; 1122 svcdata->body_start = resv->iov_base + resv->iov_len;
1123 svc_putu32(resv, 0); 1123 svc_putnl(resv, 0);
1124 svc_putu32(resv, 0); 1124 svc_putnl(resv, 0);
1125 break; 1125 break;
1126 default: 1126 default:
1127 goto auth_err; 1127 goto auth_err;
@@ -1156,7 +1156,7 @@ svcauth_gss_wrap_resp_integ(struct svc_rqst *rqstp)
1156 struct xdr_buf integ_buf; 1156 struct xdr_buf integ_buf;
1157 struct xdr_netobj mic; 1157 struct xdr_netobj mic;
1158 struct kvec *resv; 1158 struct kvec *resv;
1159 u32 *p; 1159 __be32 *p;
1160 int integ_offset, integ_len; 1160 int integ_offset, integ_len;
1161 int stat = -EINVAL; 1161 int stat = -EINVAL;
1162 1162
@@ -1199,7 +1199,7 @@ svcauth_gss_wrap_resp_integ(struct svc_rqst *rqstp)
1199 mic.data = (u8 *)resv->iov_base + resv->iov_len + 4; 1199 mic.data = (u8 *)resv->iov_base + resv->iov_len + 4;
1200 if (gss_get_mic(gsd->rsci->mechctx, &integ_buf, &mic)) 1200 if (gss_get_mic(gsd->rsci->mechctx, &integ_buf, &mic))
1201 goto out_err; 1201 goto out_err;
1202 svc_putu32(resv, htonl(mic.len)); 1202 svc_putnl(resv, mic.len);
1203 memset(mic.data + mic.len, 0, 1203 memset(mic.data + mic.len, 0,
1204 round_up_to_quad(mic.len) - mic.len); 1204 round_up_to_quad(mic.len) - mic.len);
1205 resv->iov_len += XDR_QUADLEN(mic.len) << 2; 1205 resv->iov_len += XDR_QUADLEN(mic.len) << 2;
@@ -1219,8 +1219,8 @@ svcauth_gss_wrap_resp_priv(struct svc_rqst *rqstp)
1219 struct rpc_gss_wire_cred *gc = &gsd->clcred; 1219 struct rpc_gss_wire_cred *gc = &gsd->clcred;
1220 struct xdr_buf *resbuf = &rqstp->rq_res; 1220 struct xdr_buf *resbuf = &rqstp->rq_res;
1221 struct page **inpages = NULL; 1221 struct page **inpages = NULL;
1222 u32 *p; 1222 __be32 *p, *len;
1223 int offset, *len; 1223 int offset;
1224 int pad; 1224 int pad;
1225 1225
1226 p = gsd->body_start; 1226 p = gsd->body_start;
@@ -1264,7 +1264,7 @@ svcauth_gss_wrap_resp_priv(struct svc_rqst *rqstp)
1264 return -ENOMEM; 1264 return -ENOMEM;
1265 *len = htonl(resbuf->len - offset); 1265 *len = htonl(resbuf->len - offset);
1266 pad = 3 - ((resbuf->len - offset - 1)&3); 1266 pad = 3 - ((resbuf->len - offset - 1)&3);
1267 p = (u32 *)(resbuf->tail[0].iov_base + resbuf->tail[0].iov_len); 1267 p = (__be32 *)(resbuf->tail[0].iov_base + resbuf->tail[0].iov_len);
1268 memset(p, 0, pad); 1268 memset(p, 0, pad);
1269 resbuf->tail[0].iov_len += pad; 1269 resbuf->tail[0].iov_len += pad;
1270 resbuf->len += pad; 1270 resbuf->len += pad;
diff --git a/net/sunrpc/auth_null.c b/net/sunrpc/auth_null.c
index 2eccffa96ba1..3be257dc32b2 100644
--- a/net/sunrpc/auth_null.c
+++ b/net/sunrpc/auth_null.c
@@ -60,8 +60,8 @@ nul_match(struct auth_cred *acred, struct rpc_cred *cred, int taskflags)
60/* 60/*
61 * Marshal credential. 61 * Marshal credential.
62 */ 62 */
63static u32 * 63static __be32 *
64nul_marshal(struct rpc_task *task, u32 *p) 64nul_marshal(struct rpc_task *task, __be32 *p)
65{ 65{
66 *p++ = htonl(RPC_AUTH_NULL); 66 *p++ = htonl(RPC_AUTH_NULL);
67 *p++ = 0; 67 *p++ = 0;
@@ -81,8 +81,8 @@ nul_refresh(struct rpc_task *task)
81 return 0; 81 return 0;
82} 82}
83 83
84static u32 * 84static __be32 *
85nul_validate(struct rpc_task *task, u32 *p) 85nul_validate(struct rpc_task *task, __be32 *p)
86{ 86{
87 rpc_authflavor_t flavor; 87 rpc_authflavor_t flavor;
88 u32 size; 88 u32 size;
diff --git a/net/sunrpc/auth_unix.c b/net/sunrpc/auth_unix.c
index 74c7406a1054..f7f990c9afe2 100644
--- a/net/sunrpc/auth_unix.c
+++ b/net/sunrpc/auth_unix.c
@@ -137,12 +137,12 @@ unx_match(struct auth_cred *acred, struct rpc_cred *rcred, int flags)
137 * Marshal credentials. 137 * Marshal credentials.
138 * Maybe we should keep a cached credential for performance reasons. 138 * Maybe we should keep a cached credential for performance reasons.
139 */ 139 */
140static u32 * 140static __be32 *
141unx_marshal(struct rpc_task *task, u32 *p) 141unx_marshal(struct rpc_task *task, __be32 *p)
142{ 142{
143 struct rpc_clnt *clnt = task->tk_client; 143 struct rpc_clnt *clnt = task->tk_client;
144 struct unx_cred *cred = (struct unx_cred *) task->tk_msg.rpc_cred; 144 struct unx_cred *cred = (struct unx_cred *) task->tk_msg.rpc_cred;
145 u32 *base, *hold; 145 __be32 *base, *hold;
146 int i; 146 int i;
147 147
148 *p++ = htonl(RPC_AUTH_UNIX); 148 *p++ = htonl(RPC_AUTH_UNIX);
@@ -178,8 +178,8 @@ unx_refresh(struct rpc_task *task)
178 return 0; 178 return 0;
179} 179}
180 180
181static u32 * 181static __be32 *
182unx_validate(struct rpc_task *task, u32 *p) 182unx_validate(struct rpc_task *task, __be32 *p)
183{ 183{
184 rpc_authflavor_t flavor; 184 rpc_authflavor_t flavor;
185 u32 size; 185 u32 size;
diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
index 084a0ad5c64e..124ff0ceb55b 100644
--- a/net/sunrpc/clnt.c
+++ b/net/sunrpc/clnt.c
@@ -60,8 +60,8 @@ static void call_refreshresult(struct rpc_task *task);
60static void call_timeout(struct rpc_task *task); 60static void call_timeout(struct rpc_task *task);
61static void call_connect(struct rpc_task *task); 61static void call_connect(struct rpc_task *task);
62static void call_connect_status(struct rpc_task *task); 62static void call_connect_status(struct rpc_task *task);
63static u32 * call_header(struct rpc_task *task); 63static __be32 * call_header(struct rpc_task *task);
64static u32 * call_verify(struct rpc_task *task); 64static __be32 * call_verify(struct rpc_task *task);
65 65
66 66
67static int 67static int
@@ -782,7 +782,7 @@ call_encode(struct rpc_task *task)
782 struct xdr_buf *rcvbuf = &req->rq_rcv_buf; 782 struct xdr_buf *rcvbuf = &req->rq_rcv_buf;
783 unsigned int bufsiz; 783 unsigned int bufsiz;
784 kxdrproc_t encode; 784 kxdrproc_t encode;
785 u32 *p; 785 __be32 *p;
786 786
787 dprintk("RPC: %4d call_encode (status %d)\n", 787 dprintk("RPC: %4d call_encode (status %d)\n",
788 task->tk_pid, task->tk_status); 788 task->tk_pid, task->tk_status);
@@ -1100,7 +1100,7 @@ call_decode(struct rpc_task *task)
1100 struct rpc_clnt *clnt = task->tk_client; 1100 struct rpc_clnt *clnt = task->tk_client;
1101 struct rpc_rqst *req = task->tk_rqstp; 1101 struct rpc_rqst *req = task->tk_rqstp;
1102 kxdrproc_t decode = task->tk_msg.rpc_proc->p_decode; 1102 kxdrproc_t decode = task->tk_msg.rpc_proc->p_decode;
1103 u32 *p; 1103 __be32 *p;
1104 1104
1105 dprintk("RPC: %4d call_decode (status %d)\n", 1105 dprintk("RPC: %4d call_decode (status %d)\n",
1106 task->tk_pid, task->tk_status); 1106 task->tk_pid, task->tk_status);
@@ -1197,12 +1197,12 @@ call_refreshresult(struct rpc_task *task)
1197/* 1197/*
1198 * Call header serialization 1198 * Call header serialization
1199 */ 1199 */
1200static u32 * 1200static __be32 *
1201call_header(struct rpc_task *task) 1201call_header(struct rpc_task *task)
1202{ 1202{
1203 struct rpc_clnt *clnt = task->tk_client; 1203 struct rpc_clnt *clnt = task->tk_client;
1204 struct rpc_rqst *req = task->tk_rqstp; 1204 struct rpc_rqst *req = task->tk_rqstp;
1205 u32 *p = req->rq_svec[0].iov_base; 1205 __be32 *p = req->rq_svec[0].iov_base;
1206 1206
1207 /* FIXME: check buffer size? */ 1207 /* FIXME: check buffer size? */
1208 1208
@@ -1221,12 +1221,13 @@ call_header(struct rpc_task *task)
1221/* 1221/*
1222 * Reply header verification 1222 * Reply header verification
1223 */ 1223 */
1224static u32 * 1224static __be32 *
1225call_verify(struct rpc_task *task) 1225call_verify(struct rpc_task *task)
1226{ 1226{
1227 struct kvec *iov = &task->tk_rqstp->rq_rcv_buf.head[0]; 1227 struct kvec *iov = &task->tk_rqstp->rq_rcv_buf.head[0];
1228 int len = task->tk_rqstp->rq_rcv_buf.len >> 2; 1228 int len = task->tk_rqstp->rq_rcv_buf.len >> 2;
1229 u32 *p = iov->iov_base, n; 1229 __be32 *p = iov->iov_base;
1230 u32 n;
1230 int error = -EACCES; 1231 int error = -EACCES;
1231 1232
1232 if ((task->tk_rqstp->rq_rcv_buf.len & 3) != 0) { 1233 if ((task->tk_rqstp->rq_rcv_buf.len & 3) != 0) {
@@ -1303,7 +1304,7 @@ call_verify(struct rpc_task *task)
1303 printk(KERN_WARNING "call_verify: auth check failed\n"); 1304 printk(KERN_WARNING "call_verify: auth check failed\n");
1304 goto out_garbage; /* bad verifier, retry */ 1305 goto out_garbage; /* bad verifier, retry */
1305 } 1306 }
1306 len = p - (u32 *)iov->iov_base - 1; 1307 len = p - (__be32 *)iov->iov_base - 1;
1307 if (len < 0) 1308 if (len < 0)
1308 goto out_overflow; 1309 goto out_overflow;
1309 switch ((n = ntohl(*p++))) { 1310 switch ((n = ntohl(*p++))) {
@@ -1358,12 +1359,12 @@ out_overflow:
1358 goto out_garbage; 1359 goto out_garbage;
1359} 1360}
1360 1361
1361static int rpcproc_encode_null(void *rqstp, u32 *data, void *obj) 1362static int rpcproc_encode_null(void *rqstp, __be32 *data, void *obj)
1362{ 1363{
1363 return 0; 1364 return 0;
1364} 1365}
1365 1366
1366static int rpcproc_decode_null(void *rqstp, u32 *data, void *obj) 1367static int rpcproc_decode_null(void *rqstp, __be32 *data, void *obj)
1367{ 1368{
1368 return 0; 1369 return 0;
1369} 1370}
diff --git a/net/sunrpc/pmap_clnt.c b/net/sunrpc/pmap_clnt.c
index c04609d3476a..919d5ba7ca0a 100644
--- a/net/sunrpc/pmap_clnt.c
+++ b/net/sunrpc/pmap_clnt.c
@@ -300,7 +300,7 @@ static struct rpc_clnt *pmap_create(char *hostname, struct sockaddr_in *srvaddr,
300/* 300/*
301 * XDR encode/decode functions for PMAP 301 * XDR encode/decode functions for PMAP
302 */ 302 */
303static int xdr_encode_mapping(struct rpc_rqst *req, u32 *p, struct portmap_args *map) 303static int xdr_encode_mapping(struct rpc_rqst *req, __be32 *p, struct portmap_args *map)
304{ 304{
305 dprintk("RPC: xdr_encode_mapping(%u, %u, %u, %u)\n", 305 dprintk("RPC: xdr_encode_mapping(%u, %u, %u, %u)\n",
306 map->pm_prog, map->pm_vers, map->pm_prot, map->pm_port); 306 map->pm_prog, map->pm_vers, map->pm_prot, map->pm_port);
@@ -313,13 +313,13 @@ static int xdr_encode_mapping(struct rpc_rqst *req, u32 *p, struct portmap_args
313 return 0; 313 return 0;
314} 314}
315 315
316static int xdr_decode_port(struct rpc_rqst *req, u32 *p, unsigned short *portp) 316static int xdr_decode_port(struct rpc_rqst *req, __be32 *p, unsigned short *portp)
317{ 317{
318 *portp = (unsigned short) ntohl(*p++); 318 *portp = (unsigned short) ntohl(*p++);
319 return 0; 319 return 0;
320} 320}
321 321
322static int xdr_decode_bool(struct rpc_rqst *req, u32 *p, unsigned int *boolp) 322static int xdr_decode_bool(struct rpc_rqst *req, __be32 *p, unsigned int *boolp)
323{ 323{
324 *boolp = (unsigned int) ntohl(*p++); 324 *boolp = (unsigned int) ntohl(*p++);
325 return 0; 325 return 0;
diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c
index b76a227dd3ad..44b8d9d4c18a 100644
--- a/net/sunrpc/svc.c
+++ b/net/sunrpc/svc.c
@@ -256,11 +256,11 @@ svc_process(struct svc_serv *serv, struct svc_rqst *rqstp)
256 struct kvec * argv = &rqstp->rq_arg.head[0]; 256 struct kvec * argv = &rqstp->rq_arg.head[0];
257 struct kvec * resv = &rqstp->rq_res.head[0]; 257 struct kvec * resv = &rqstp->rq_res.head[0];
258 kxdrproc_t xdr; 258 kxdrproc_t xdr;
259 u32 *statp; 259 __be32 *statp;
260 u32 dir, prog, vers, proc, 260 u32 dir, prog, vers, proc;
261 auth_stat, rpc_stat; 261 __be32 auth_stat, rpc_stat;
262 int auth_res; 262 int auth_res;
263 u32 *accept_statp; 263 __be32 *accept_statp;
264 264
265 rpc_stat = rpc_success; 265 rpc_stat = rpc_success;
266 266
@@ -284,16 +284,16 @@ svc_process(struct svc_serv *serv, struct svc_rqst *rqstp)
284 rqstp->rq_sendfile_ok = 1; 284 rqstp->rq_sendfile_ok = 1;
285 /* tcp needs a space for the record length... */ 285 /* tcp needs a space for the record length... */
286 if (rqstp->rq_prot == IPPROTO_TCP) 286 if (rqstp->rq_prot == IPPROTO_TCP)
287 svc_putu32(resv, 0); 287 svc_putnl(resv, 0);
288 288
289 rqstp->rq_xid = svc_getu32(argv); 289 rqstp->rq_xid = svc_getu32(argv);
290 svc_putu32(resv, rqstp->rq_xid); 290 svc_putu32(resv, rqstp->rq_xid);
291 291
292 dir = ntohl(svc_getu32(argv)); 292 dir = svc_getnl(argv);
293 vers = ntohl(svc_getu32(argv)); 293 vers = svc_getnl(argv);
294 294
295 /* First words of reply: */ 295 /* First words of reply: */
296 svc_putu32(resv, xdr_one); /* REPLY */ 296 svc_putnl(resv, 1); /* REPLY */
297 297
298 if (dir != 0) /* direction != CALL */ 298 if (dir != 0) /* direction != CALL */
299 goto err_bad_dir; 299 goto err_bad_dir;
@@ -303,11 +303,11 @@ svc_process(struct svc_serv *serv, struct svc_rqst *rqstp)
303 /* Save position in case we later decide to reject: */ 303 /* Save position in case we later decide to reject: */
304 accept_statp = resv->iov_base + resv->iov_len; 304 accept_statp = resv->iov_base + resv->iov_len;
305 305
306 svc_putu32(resv, xdr_zero); /* ACCEPT */ 306 svc_putnl(resv, 0); /* ACCEPT */
307 307
308 rqstp->rq_prog = prog = ntohl(svc_getu32(argv)); /* program number */ 308 rqstp->rq_prog = prog = svc_getnl(argv); /* program number */
309 rqstp->rq_vers = vers = ntohl(svc_getu32(argv)); /* version number */ 309 rqstp->rq_vers = vers = svc_getnl(argv); /* version number */
310 rqstp->rq_proc = proc = ntohl(svc_getu32(argv)); /* procedure number */ 310 rqstp->rq_proc = proc = svc_getnl(argv); /* procedure number */
311 311
312 progp = serv->sv_program; 312 progp = serv->sv_program;
313 313
@@ -361,7 +361,7 @@ svc_process(struct svc_serv *serv, struct svc_rqst *rqstp)
361 361
362 /* Build the reply header. */ 362 /* Build the reply header. */
363 statp = resv->iov_base +resv->iov_len; 363 statp = resv->iov_base +resv->iov_len;
364 svc_putu32(resv, rpc_success); /* RPC_SUCCESS */ 364 svc_putnl(resv, RPC_SUCCESS);
365 365
366 /* Bump per-procedure stats counter */ 366 /* Bump per-procedure stats counter */
367 procp->pc_count++; 367 procp->pc_count++;
@@ -439,10 +439,10 @@ err_bad_dir:
439 439
440err_bad_rpc: 440err_bad_rpc:
441 serv->sv_stats->rpcbadfmt++; 441 serv->sv_stats->rpcbadfmt++;
442 svc_putu32(resv, xdr_one); /* REJECT */ 442 svc_putnl(resv, 1); /* REJECT */
443 svc_putu32(resv, xdr_zero); /* RPC_MISMATCH */ 443 svc_putnl(resv, 0); /* RPC_MISMATCH */
444 svc_putu32(resv, xdr_two); /* Only RPCv2 supported */ 444 svc_putnl(resv, 2); /* Only RPCv2 supported */
445 svc_putu32(resv, xdr_two); 445 svc_putnl(resv, 2);
446 goto sendit; 446 goto sendit;
447 447
448err_bad_auth: 448err_bad_auth:
@@ -450,15 +450,15 @@ err_bad_auth:
450 serv->sv_stats->rpcbadauth++; 450 serv->sv_stats->rpcbadauth++;
451 /* Restore write pointer to location of accept status: */ 451 /* Restore write pointer to location of accept status: */
452 xdr_ressize_check(rqstp, accept_statp); 452 xdr_ressize_check(rqstp, accept_statp);
453 svc_putu32(resv, xdr_one); /* REJECT */ 453 svc_putnl(resv, 1); /* REJECT */
454 svc_putu32(resv, xdr_one); /* AUTH_ERROR */ 454 svc_putnl(resv, 1); /* AUTH_ERROR */
455 svc_putu32(resv, auth_stat); /* status */ 455 svc_putnl(resv, ntohl(auth_stat)); /* status */
456 goto sendit; 456 goto sendit;
457 457
458err_bad_prog: 458err_bad_prog:
459 dprintk("svc: unknown program %d\n", prog); 459 dprintk("svc: unknown program %d\n", prog);
460 serv->sv_stats->rpcbadfmt++; 460 serv->sv_stats->rpcbadfmt++;
461 svc_putu32(resv, rpc_prog_unavail); 461 svc_putnl(resv, RPC_PROG_UNAVAIL);
462 goto sendit; 462 goto sendit;
463 463
464err_bad_vers: 464err_bad_vers:
@@ -466,9 +466,9 @@ err_bad_vers:
466 printk("svc: unknown version (%d)\n", vers); 466 printk("svc: unknown version (%d)\n", vers);
467#endif 467#endif
468 serv->sv_stats->rpcbadfmt++; 468 serv->sv_stats->rpcbadfmt++;
469 svc_putu32(resv, rpc_prog_mismatch); 469 svc_putnl(resv, RPC_PROG_MISMATCH);
470 svc_putu32(resv, htonl(progp->pg_lovers)); 470 svc_putnl(resv, progp->pg_lovers);
471 svc_putu32(resv, htonl(progp->pg_hivers)); 471 svc_putnl(resv, progp->pg_hivers);
472 goto sendit; 472 goto sendit;
473 473
474err_bad_proc: 474err_bad_proc:
@@ -476,7 +476,7 @@ err_bad_proc:
476 printk("svc: unknown procedure (%d)\n", proc); 476 printk("svc: unknown procedure (%d)\n", proc);
477#endif 477#endif
478 serv->sv_stats->rpcbadfmt++; 478 serv->sv_stats->rpcbadfmt++;
479 svc_putu32(resv, rpc_proc_unavail); 479 svc_putnl(resv, RPC_PROC_UNAVAIL);
480 goto sendit; 480 goto sendit;
481 481
482err_garbage: 482err_garbage:
@@ -486,6 +486,6 @@ err_garbage:
486 rpc_stat = rpc_garbage_args; 486 rpc_stat = rpc_garbage_args;
487err_bad: 487err_bad:
488 serv->sv_stats->rpcbadfmt++; 488 serv->sv_stats->rpcbadfmt++;
489 svc_putu32(resv, rpc_stat); 489 svc_putnl(resv, ntohl(rpc_stat));
490 goto sendit; 490 goto sendit;
491} 491}
diff --git a/net/sunrpc/svcauth.c b/net/sunrpc/svcauth.c
index 5b28c6176806..8f2320aded5c 100644
--- a/net/sunrpc/svcauth.c
+++ b/net/sunrpc/svcauth.c
@@ -35,14 +35,14 @@ static struct auth_ops *authtab[RPC_AUTH_MAXFLAVOR] = {
35}; 35};
36 36
37int 37int
38svc_authenticate(struct svc_rqst *rqstp, u32 *authp) 38svc_authenticate(struct svc_rqst *rqstp, __be32 *authp)
39{ 39{
40 rpc_authflavor_t flavor; 40 rpc_authflavor_t flavor;
41 struct auth_ops *aops; 41 struct auth_ops *aops;
42 42
43 *authp = rpc_auth_ok; 43 *authp = rpc_auth_ok;
44 44
45 flavor = ntohl(svc_getu32(&rqstp->rq_arg.head[0])); 45 flavor = svc_getnl(&rqstp->rq_arg.head[0]);
46 46
47 dprintk("svc: svc_authenticate (%d)\n", flavor); 47 dprintk("svc: svc_authenticate (%d)\n", flavor);
48 48
diff --git a/net/sunrpc/svcauth_unix.c b/net/sunrpc/svcauth_unix.c
index 7e5707e2d6b6..1020d54b01d0 100644
--- a/net/sunrpc/svcauth_unix.c
+++ b/net/sunrpc/svcauth_unix.c
@@ -145,7 +145,7 @@ static void ip_map_request(struct cache_detail *cd,
145{ 145{
146 char text_addr[20]; 146 char text_addr[20];
147 struct ip_map *im = container_of(h, struct ip_map, h); 147 struct ip_map *im = container_of(h, struct ip_map, h);
148 __u32 addr = im->m_addr.s_addr; 148 __be32 addr = im->m_addr.s_addr;
149 149
150 snprintf(text_addr, 20, "%u.%u.%u.%u", 150 snprintf(text_addr, 20, "%u.%u.%u.%u",
151 ntohl(addr) >> 24 & 0xff, 151 ntohl(addr) >> 24 & 0xff,
@@ -249,10 +249,10 @@ static int ip_map_show(struct seq_file *m,
249 249
250 seq_printf(m, "%s %d.%d.%d.%d %s\n", 250 seq_printf(m, "%s %d.%d.%d.%d %s\n",
251 im->m_class, 251 im->m_class,
252 htonl(addr.s_addr) >> 24 & 0xff, 252 ntohl(addr.s_addr) >> 24 & 0xff,
253 htonl(addr.s_addr) >> 16 & 0xff, 253 ntohl(addr.s_addr) >> 16 & 0xff,
254 htonl(addr.s_addr) >> 8 & 0xff, 254 ntohl(addr.s_addr) >> 8 & 0xff,
255 htonl(addr.s_addr) >> 0 & 0xff, 255 ntohl(addr.s_addr) >> 0 & 0xff,
256 dom 256 dom
257 ); 257 );
258 return 0; 258 return 0;
@@ -410,7 +410,7 @@ svcauth_unix_set_client(struct svc_rqst *rqstp)
410} 410}
411 411
412static int 412static int
413svcauth_null_accept(struct svc_rqst *rqstp, u32 *authp) 413svcauth_null_accept(struct svc_rqst *rqstp, __be32 *authp)
414{ 414{
415 struct kvec *argv = &rqstp->rq_arg.head[0]; 415 struct kvec *argv = &rqstp->rq_arg.head[0];
416 struct kvec *resv = &rqstp->rq_res.head[0]; 416 struct kvec *resv = &rqstp->rq_res.head[0];
@@ -427,7 +427,7 @@ svcauth_null_accept(struct svc_rqst *rqstp, u32 *authp)
427 *authp = rpc_autherr_badcred; 427 *authp = rpc_autherr_badcred;
428 return SVC_DENIED; 428 return SVC_DENIED;
429 } 429 }
430 if (svc_getu32(argv) != RPC_AUTH_NULL || svc_getu32(argv) != 0) { 430 if (svc_getu32(argv) != htonl(RPC_AUTH_NULL) || svc_getu32(argv) != 0) {
431 dprintk("svc: bad null verf\n"); 431 dprintk("svc: bad null verf\n");
432 *authp = rpc_autherr_badverf; 432 *authp = rpc_autherr_badverf;
433 return SVC_DENIED; 433 return SVC_DENIED;
@@ -441,8 +441,8 @@ svcauth_null_accept(struct svc_rqst *rqstp, u32 *authp)
441 return SVC_DROP; /* kmalloc failure - client must retry */ 441 return SVC_DROP; /* kmalloc failure - client must retry */
442 442
443 /* Put NULL verifier */ 443 /* Put NULL verifier */
444 svc_putu32(resv, RPC_AUTH_NULL); 444 svc_putnl(resv, RPC_AUTH_NULL);
445 svc_putu32(resv, 0); 445 svc_putnl(resv, 0);
446 446
447 return SVC_OK; 447 return SVC_OK;
448} 448}
@@ -472,7 +472,7 @@ struct auth_ops svcauth_null = {
472 472
473 473
474static int 474static int
475svcauth_unix_accept(struct svc_rqst *rqstp, u32 *authp) 475svcauth_unix_accept(struct svc_rqst *rqstp, __be32 *authp)
476{ 476{
477 struct kvec *argv = &rqstp->rq_arg.head[0]; 477 struct kvec *argv = &rqstp->rq_arg.head[0];
478 struct kvec *resv = &rqstp->rq_res.head[0]; 478 struct kvec *resv = &rqstp->rq_res.head[0];
@@ -488,31 +488,31 @@ svcauth_unix_accept(struct svc_rqst *rqstp, u32 *authp)
488 488
489 svc_getu32(argv); /* length */ 489 svc_getu32(argv); /* length */
490 svc_getu32(argv); /* time stamp */ 490 svc_getu32(argv); /* time stamp */
491 slen = XDR_QUADLEN(ntohl(svc_getu32(argv))); /* machname length */ 491 slen = XDR_QUADLEN(svc_getnl(argv)); /* machname length */
492 if (slen > 64 || (len -= (slen + 3)*4) < 0) 492 if (slen > 64 || (len -= (slen + 3)*4) < 0)
493 goto badcred; 493 goto badcred;
494 argv->iov_base = (void*)((u32*)argv->iov_base + slen); /* skip machname */ 494 argv->iov_base = (void*)((__be32*)argv->iov_base + slen); /* skip machname */
495 argv->iov_len -= slen*4; 495 argv->iov_len -= slen*4;
496 496
497 cred->cr_uid = ntohl(svc_getu32(argv)); /* uid */ 497 cred->cr_uid = svc_getnl(argv); /* uid */
498 cred->cr_gid = ntohl(svc_getu32(argv)); /* gid */ 498 cred->cr_gid = svc_getnl(argv); /* gid */
499 slen = ntohl(svc_getu32(argv)); /* gids length */ 499 slen = svc_getnl(argv); /* gids length */
500 if (slen > 16 || (len -= (slen + 2)*4) < 0) 500 if (slen > 16 || (len -= (slen + 2)*4) < 0)
501 goto badcred; 501 goto badcred;
502 cred->cr_group_info = groups_alloc(slen); 502 cred->cr_group_info = groups_alloc(slen);
503 if (cred->cr_group_info == NULL) 503 if (cred->cr_group_info == NULL)
504 return SVC_DROP; 504 return SVC_DROP;
505 for (i = 0; i < slen; i++) 505 for (i = 0; i < slen; i++)
506 GROUP_AT(cred->cr_group_info, i) = ntohl(svc_getu32(argv)); 506 GROUP_AT(cred->cr_group_info, i) = svc_getnl(argv);
507 507
508 if (svc_getu32(argv) != RPC_AUTH_NULL || svc_getu32(argv) != 0) { 508 if (svc_getu32(argv) != htonl(RPC_AUTH_NULL) || svc_getu32(argv) != 0) {
509 *authp = rpc_autherr_badverf; 509 *authp = rpc_autherr_badverf;
510 return SVC_DENIED; 510 return SVC_DENIED;
511 } 511 }
512 512
513 /* Put NULL verifier */ 513 /* Put NULL verifier */
514 svc_putu32(resv, RPC_AUTH_NULL); 514 svc_putnl(resv, RPC_AUTH_NULL);
515 svc_putu32(resv, 0); 515 svc_putnl(resv, 0);
516 516
517 return SVC_OK; 517 return SVC_OK;
518 518
diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c
index 953aff89bcac..5b0fe1b66a23 100644
--- a/net/sunrpc/svcsock.c
+++ b/net/sunrpc/svcsock.c
@@ -1030,7 +1030,7 @@ svc_tcp_sendto(struct svc_rqst *rqstp)
1030{ 1030{
1031 struct xdr_buf *xbufp = &rqstp->rq_res; 1031 struct xdr_buf *xbufp = &rqstp->rq_res;
1032 int sent; 1032 int sent;
1033 u32 reclen; 1033 __be32 reclen;
1034 1034
1035 /* Set up the first element of the reply kvec. 1035 /* Set up the first element of the reply kvec.
1036 * Any other kvecs that may be in use have been taken 1036 * Any other kvecs that may be in use have been taken
@@ -1393,14 +1393,12 @@ svc_create_socket(struct svc_serv *serv, int protocol, struct sockaddr_in *sin)
1393 if ((error = sock_create_kern(PF_INET, type, protocol, &sock)) < 0) 1393 if ((error = sock_create_kern(PF_INET, type, protocol, &sock)) < 0)
1394 return error; 1394 return error;
1395 1395
1396 if (sin != NULL) { 1396 if (type == SOCK_STREAM)
1397 if (type == SOCK_STREAM) 1397 sock->sk->sk_reuse = 1; /* allow address reuse */
1398 sock->sk->sk_reuse = 1; /* allow address reuse */ 1398 error = kernel_bind(sock, (struct sockaddr *) sin,
1399 error = kernel_bind(sock, (struct sockaddr *) sin, 1399 sizeof(*sin));
1400 sizeof(*sin)); 1400 if (error < 0)
1401 if (error < 0) 1401 goto bummer;
1402 goto bummer;
1403 }
1404 1402
1405 if (protocol == IPPROTO_TCP) { 1403 if (protocol == IPPROTO_TCP) {
1406 if ((error = kernel_listen(sock, 64)) < 0) 1404 if ((error = kernel_listen(sock, 64)) < 0)
diff --git a/net/sunrpc/xdr.c b/net/sunrpc/xdr.c
index 6ac45103a272..9022eb8b37ed 100644
--- a/net/sunrpc/xdr.c
+++ b/net/sunrpc/xdr.c
@@ -18,8 +18,8 @@
18/* 18/*
19 * XDR functions for basic NFS types 19 * XDR functions for basic NFS types
20 */ 20 */
21u32 * 21__be32 *
22xdr_encode_netobj(u32 *p, const struct xdr_netobj *obj) 22xdr_encode_netobj(__be32 *p, const struct xdr_netobj *obj)
23{ 23{
24 unsigned int quadlen = XDR_QUADLEN(obj->len); 24 unsigned int quadlen = XDR_QUADLEN(obj->len);
25 25
@@ -29,8 +29,8 @@ xdr_encode_netobj(u32 *p, const struct xdr_netobj *obj)
29 return p + XDR_QUADLEN(obj->len); 29 return p + XDR_QUADLEN(obj->len);
30} 30}
31 31
32u32 * 32__be32 *
33xdr_decode_netobj(u32 *p, struct xdr_netobj *obj) 33xdr_decode_netobj(__be32 *p, struct xdr_netobj *obj)
34{ 34{
35 unsigned int len; 35 unsigned int len;
36 36
@@ -55,7 +55,7 @@ xdr_decode_netobj(u32 *p, struct xdr_netobj *obj)
55 * Returns the updated current XDR buffer position 55 * Returns the updated current XDR buffer position
56 * 56 *
57 */ 57 */
58u32 *xdr_encode_opaque_fixed(u32 *p, const void *ptr, unsigned int nbytes) 58__be32 *xdr_encode_opaque_fixed(__be32 *p, const void *ptr, unsigned int nbytes)
59{ 59{
60 if (likely(nbytes != 0)) { 60 if (likely(nbytes != 0)) {
61 unsigned int quadlen = XDR_QUADLEN(nbytes); 61 unsigned int quadlen = XDR_QUADLEN(nbytes);
@@ -79,21 +79,21 @@ EXPORT_SYMBOL(xdr_encode_opaque_fixed);
79 * 79 *
80 * Returns the updated current XDR buffer position 80 * Returns the updated current XDR buffer position
81 */ 81 */
82u32 *xdr_encode_opaque(u32 *p, const void *ptr, unsigned int nbytes) 82__be32 *xdr_encode_opaque(__be32 *p, const void *ptr, unsigned int nbytes)
83{ 83{
84 *p++ = htonl(nbytes); 84 *p++ = htonl(nbytes);
85 return xdr_encode_opaque_fixed(p, ptr, nbytes); 85 return xdr_encode_opaque_fixed(p, ptr, nbytes);
86} 86}
87EXPORT_SYMBOL(xdr_encode_opaque); 87EXPORT_SYMBOL(xdr_encode_opaque);
88 88
89u32 * 89__be32 *
90xdr_encode_string(u32 *p, const char *string) 90xdr_encode_string(__be32 *p, const char *string)
91{ 91{
92 return xdr_encode_array(p, string, strlen(string)); 92 return xdr_encode_array(p, string, strlen(string));
93} 93}
94 94
95u32 * 95__be32 *
96xdr_decode_string_inplace(u32 *p, char **sp, int *lenp, int maxlen) 96xdr_decode_string_inplace(__be32 *p, char **sp, int *lenp, int maxlen)
97{ 97{
98 unsigned int len; 98 unsigned int len;
99 99
@@ -432,7 +432,7 @@ xdr_shift_buf(struct xdr_buf *buf, size_t len)
432 * of the buffer length, and takes care of adjusting the kvec 432 * of the buffer length, and takes care of adjusting the kvec
433 * length for us. 433 * length for us.
434 */ 434 */
435void xdr_init_encode(struct xdr_stream *xdr, struct xdr_buf *buf, uint32_t *p) 435void xdr_init_encode(struct xdr_stream *xdr, struct xdr_buf *buf, __be32 *p)
436{ 436{
437 struct kvec *iov = buf->head; 437 struct kvec *iov = buf->head;
438 int scratch_len = buf->buflen - buf->page_len - buf->tail[0].iov_len; 438 int scratch_len = buf->buflen - buf->page_len - buf->tail[0].iov_len;
@@ -440,8 +440,8 @@ void xdr_init_encode(struct xdr_stream *xdr, struct xdr_buf *buf, uint32_t *p)
440 BUG_ON(scratch_len < 0); 440 BUG_ON(scratch_len < 0);
441 xdr->buf = buf; 441 xdr->buf = buf;
442 xdr->iov = iov; 442 xdr->iov = iov;
443 xdr->p = (uint32_t *)((char *)iov->iov_base + iov->iov_len); 443 xdr->p = (__be32 *)((char *)iov->iov_base + iov->iov_len);
444 xdr->end = (uint32_t *)((char *)iov->iov_base + scratch_len); 444 xdr->end = (__be32 *)((char *)iov->iov_base + scratch_len);
445 BUG_ON(iov->iov_len > scratch_len); 445 BUG_ON(iov->iov_len > scratch_len);
446 446
447 if (p != xdr->p && p != NULL) { 447 if (p != xdr->p && p != NULL) {
@@ -465,10 +465,10 @@ EXPORT_SYMBOL(xdr_init_encode);
465 * bytes of data. If so, update the total xdr_buf length, and 465 * bytes of data. If so, update the total xdr_buf length, and
466 * adjust the length of the current kvec. 466 * adjust the length of the current kvec.
467 */ 467 */
468uint32_t * xdr_reserve_space(struct xdr_stream *xdr, size_t nbytes) 468__be32 * xdr_reserve_space(struct xdr_stream *xdr, size_t nbytes)
469{ 469{
470 uint32_t *p = xdr->p; 470 __be32 *p = xdr->p;
471 uint32_t *q; 471 __be32 *q;
472 472
473 /* align nbytes on the next 32-bit boundary */ 473 /* align nbytes on the next 32-bit boundary */
474 nbytes += 3; 474 nbytes += 3;
@@ -524,7 +524,7 @@ EXPORT_SYMBOL(xdr_write_pages);
524 * @buf: pointer to XDR buffer from which to decode data 524 * @buf: pointer to XDR buffer from which to decode data
525 * @p: current pointer inside XDR buffer 525 * @p: current pointer inside XDR buffer
526 */ 526 */
527void xdr_init_decode(struct xdr_stream *xdr, struct xdr_buf *buf, uint32_t *p) 527void xdr_init_decode(struct xdr_stream *xdr, struct xdr_buf *buf, __be32 *p)
528{ 528{
529 struct kvec *iov = buf->head; 529 struct kvec *iov = buf->head;
530 unsigned int len = iov->iov_len; 530 unsigned int len = iov->iov_len;
@@ -534,7 +534,7 @@ void xdr_init_decode(struct xdr_stream *xdr, struct xdr_buf *buf, uint32_t *p)
534 xdr->buf = buf; 534 xdr->buf = buf;
535 xdr->iov = iov; 535 xdr->iov = iov;
536 xdr->p = p; 536 xdr->p = p;
537 xdr->end = (uint32_t *)((char *)iov->iov_base + len); 537 xdr->end = (__be32 *)((char *)iov->iov_base + len);
538} 538}
539EXPORT_SYMBOL(xdr_init_decode); 539EXPORT_SYMBOL(xdr_init_decode);
540 540
@@ -548,10 +548,10 @@ EXPORT_SYMBOL(xdr_init_decode);
548 * If so return the current pointer, then update the current 548 * If so return the current pointer, then update the current
549 * pointer position. 549 * pointer position.
550 */ 550 */
551uint32_t * xdr_inline_decode(struct xdr_stream *xdr, size_t nbytes) 551__be32 * xdr_inline_decode(struct xdr_stream *xdr, size_t nbytes)
552{ 552{
553 uint32_t *p = xdr->p; 553 __be32 *p = xdr->p;
554 uint32_t *q = p + XDR_QUADLEN(nbytes); 554 __be32 *q = p + XDR_QUADLEN(nbytes);
555 555
556 if (unlikely(q > xdr->end || q < p)) 556 if (unlikely(q > xdr->end || q < p))
557 return NULL; 557 return NULL;
@@ -599,8 +599,8 @@ void xdr_read_pages(struct xdr_stream *xdr, unsigned int len)
599 * Position current pointer at beginning of tail, and 599 * Position current pointer at beginning of tail, and
600 * set remaining message length. 600 * set remaining message length.
601 */ 601 */
602 xdr->p = (uint32_t *)((char *)iov->iov_base + padding); 602 xdr->p = (__be32 *)((char *)iov->iov_base + padding);
603 xdr->end = (uint32_t *)((char *)iov->iov_base + end); 603 xdr->end = (__be32 *)((char *)iov->iov_base + end);
604} 604}
605EXPORT_SYMBOL(xdr_read_pages); 605EXPORT_SYMBOL(xdr_read_pages);
606 606
@@ -624,8 +624,8 @@ void xdr_enter_page(struct xdr_stream *xdr, unsigned int len)
624 */ 624 */
625 if (len > PAGE_CACHE_SIZE - xdr->buf->page_base) 625 if (len > PAGE_CACHE_SIZE - xdr->buf->page_base)
626 len = PAGE_CACHE_SIZE - xdr->buf->page_base; 626 len = PAGE_CACHE_SIZE - xdr->buf->page_base;
627 xdr->p = (uint32_t *)(kaddr + xdr->buf->page_base); 627 xdr->p = (__be32 *)(kaddr + xdr->buf->page_base);
628 xdr->end = (uint32_t *)((char *)xdr->p + len); 628 xdr->end = (__be32 *)((char *)xdr->p + len);
629} 629}
630EXPORT_SYMBOL(xdr_enter_page); 630EXPORT_SYMBOL(xdr_enter_page);
631 631
@@ -743,7 +743,7 @@ out:
743int 743int
744xdr_decode_word(struct xdr_buf *buf, int base, u32 *obj) 744xdr_decode_word(struct xdr_buf *buf, int base, u32 *obj)
745{ 745{
746 u32 raw; 746 __be32 raw;
747 int status; 747 int status;
748 748
749 status = read_bytes_from_xdr_buf(buf, base, &raw, sizeof(*obj)); 749 status = read_bytes_from_xdr_buf(buf, base, &raw, sizeof(*obj));
@@ -756,7 +756,7 @@ xdr_decode_word(struct xdr_buf *buf, int base, u32 *obj)
756int 756int
757xdr_encode_word(struct xdr_buf *buf, int base, u32 obj) 757xdr_encode_word(struct xdr_buf *buf, int base, u32 obj)
758{ 758{
759 u32 raw = htonl(obj); 759 __be32 raw = htonl(obj);
760 760
761 return write_bytes_to_xdr_buf(buf, base, &raw, sizeof(obj)); 761 return write_bytes_to_xdr_buf(buf, base, &raw, sizeof(obj));
762} 762}
diff --git a/net/sunrpc/xprt.c b/net/sunrpc/xprt.c
index 1f786f68729d..80857470dc11 100644
--- a/net/sunrpc/xprt.c
+++ b/net/sunrpc/xprt.c
@@ -594,7 +594,7 @@ static void xprt_connect_status(struct rpc_task *task)
594 * @xid: RPC XID of incoming reply 594 * @xid: RPC XID of incoming reply
595 * 595 *
596 */ 596 */
597struct rpc_rqst *xprt_lookup_rqst(struct rpc_xprt *xprt, u32 xid) 597struct rpc_rqst *xprt_lookup_rqst(struct rpc_xprt *xprt, __be32 xid)
598{ 598{
599 struct list_head *pos; 599 struct list_head *pos;
600 600
@@ -801,7 +801,7 @@ void xprt_reserve(struct rpc_task *task)
801 spin_unlock(&xprt->reserve_lock); 801 spin_unlock(&xprt->reserve_lock);
802} 802}
803 803
804static inline u32 xprt_alloc_xid(struct rpc_xprt *xprt) 804static inline __be32 xprt_alloc_xid(struct rpc_xprt *xprt)
805{ 805{
806 return xprt->xid++; 806 return xprt->xid++;
807} 807}
diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c
index 9b62923a9c06..28100e019225 100644
--- a/net/sunrpc/xprtsock.c
+++ b/net/sunrpc/xprtsock.c
@@ -548,7 +548,8 @@ static void xs_udp_data_ready(struct sock *sk, int len)
548 struct rpc_rqst *rovr; 548 struct rpc_rqst *rovr;
549 struct sk_buff *skb; 549 struct sk_buff *skb;
550 int err, repsize, copied; 550 int err, repsize, copied;
551 u32 _xid, *xp; 551 u32 _xid;
552 __be32 *xp;
552 553
553 read_lock(&sk->sk_callback_lock); 554 read_lock(&sk->sk_callback_lock);
554 dprintk("RPC: xs_udp_data_ready...\n"); 555 dprintk("RPC: xs_udp_data_ready...\n");
diff --git a/net/xfrm/xfrm_hash.h b/net/xfrm/xfrm_hash.h
index d3abb0b7dc62..6ac4e4f033ac 100644
--- a/net/xfrm/xfrm_hash.h
+++ b/net/xfrm/xfrm_hash.h
@@ -58,10 +58,10 @@ static inline unsigned __xfrm_src_hash(xfrm_address_t *saddr,
58} 58}
59 59
60static inline unsigned int 60static inline unsigned int
61__xfrm_spi_hash(xfrm_address_t *daddr, u32 spi, u8 proto, unsigned short family, 61__xfrm_spi_hash(xfrm_address_t *daddr, __be32 spi, u8 proto, unsigned short family,
62 unsigned int hmask) 62 unsigned int hmask)
63{ 63{
64 unsigned int h = spi ^ proto; 64 unsigned int h = (__force u32)spi ^ proto;
65 switch (family) { 65 switch (family) {
66 case AF_INET: 66 case AF_INET:
67 h ^= __xfrm4_addr_hash(daddr); 67 h ^= __xfrm4_addr_hash(daddr);
diff --git a/net/xfrm/xfrm_input.c b/net/xfrm/xfrm_input.c
index dfc90bb1cf1f..e8198a2c785d 100644
--- a/net/xfrm/xfrm_input.c
+++ b/net/xfrm/xfrm_input.c
@@ -46,7 +46,7 @@ EXPORT_SYMBOL(secpath_dup);
46 46
47/* Fetch spi and seq from ipsec header */ 47/* Fetch spi and seq from ipsec header */
48 48
49int xfrm_parse_spi(struct sk_buff *skb, u8 nexthdr, u32 *spi, u32 *seq) 49int xfrm_parse_spi(struct sk_buff *skb, u8 nexthdr, __be32 *spi, __be32 *seq)
50{ 50{
51 int offset, offset_seq; 51 int offset, offset_seq;
52 52
@@ -62,7 +62,7 @@ int xfrm_parse_spi(struct sk_buff *skb, u8 nexthdr, u32 *spi, u32 *seq)
62 case IPPROTO_COMP: 62 case IPPROTO_COMP:
63 if (!pskb_may_pull(skb, sizeof(struct ip_comp_hdr))) 63 if (!pskb_may_pull(skb, sizeof(struct ip_comp_hdr)))
64 return -EINVAL; 64 return -EINVAL;
65 *spi = htonl(ntohs(*(u16*)(skb->h.raw + 2))); 65 *spi = htonl(ntohs(*(__be16*)(skb->h.raw + 2)));
66 *seq = 0; 66 *seq = 0;
67 return 0; 67 return 0;
68 default: 68 default:
@@ -72,8 +72,8 @@ int xfrm_parse_spi(struct sk_buff *skb, u8 nexthdr, u32 *spi, u32 *seq)
72 if (!pskb_may_pull(skb, 16)) 72 if (!pskb_may_pull(skb, 16))
73 return -EINVAL; 73 return -EINVAL;
74 74
75 *spi = *(u32*)(skb->h.raw + offset); 75 *spi = *(__be32*)(skb->h.raw + offset);
76 *seq = *(u32*)(skb->h.raw + offset_seq); 76 *seq = *(__be32*)(skb->h.raw + offset_seq);
77 return 0; 77 return 0;
78} 78}
79EXPORT_SYMBOL(xfrm_parse_spi); 79EXPORT_SYMBOL(xfrm_parse_spi);
diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
index 9f63edd39346..f927b7330f02 100644
--- a/net/xfrm/xfrm_state.c
+++ b/net/xfrm/xfrm_state.c
@@ -70,7 +70,7 @@ static inline unsigned int xfrm_src_hash(xfrm_address_t *addr,
70} 70}
71 71
72static inline unsigned int 72static inline unsigned int
73xfrm_spi_hash(xfrm_address_t *daddr, u32 spi, u8 proto, unsigned short family) 73xfrm_spi_hash(xfrm_address_t *daddr, __be32 spi, u8 proto, unsigned short family)
74{ 74{
75 return __xfrm_spi_hash(daddr, spi, proto, family, xfrm_state_hmask); 75 return __xfrm_spi_hash(daddr, spi, proto, family, xfrm_state_hmask);
76} 76}
@@ -96,9 +96,12 @@ static void xfrm_hash_transfer(struct hlist_head *list,
96 nhashmask); 96 nhashmask);
97 hlist_add_head(&x->bysrc, nsrctable+h); 97 hlist_add_head(&x->bysrc, nsrctable+h);
98 98
99 h = __xfrm_spi_hash(&x->id.daddr, x->id.spi, x->id.proto, 99 if (x->id.spi) {
100 x->props.family, nhashmask); 100 h = __xfrm_spi_hash(&x->id.daddr, x->id.spi,
101 hlist_add_head(&x->byspi, nspitable+h); 101 x->id.proto, x->props.family,
102 nhashmask);
103 hlist_add_head(&x->byspi, nspitable+h);
104 }
102 } 105 }
103} 106}
104 107
@@ -421,7 +424,7 @@ xfrm_init_tempsel(struct xfrm_state *x, struct flowi *fl,
421 return 0; 424 return 0;
422} 425}
423 426
424static struct xfrm_state *__xfrm_state_lookup(xfrm_address_t *daddr, u32 spi, u8 proto, unsigned short family) 427static struct xfrm_state *__xfrm_state_lookup(xfrm_address_t *daddr, __be32 spi, u8 proto, unsigned short family)
425{ 428{
426 unsigned int h = xfrm_spi_hash(daddr, spi, proto, family); 429 unsigned int h = xfrm_spi_hash(daddr, spi, proto, family);
427 struct xfrm_state *x; 430 struct xfrm_state *x;
@@ -622,7 +625,7 @@ static void __xfrm_state_insert(struct xfrm_state *x)
622 h = xfrm_src_hash(&x->props.saddr, x->props.family); 625 h = xfrm_src_hash(&x->props.saddr, x->props.family);
623 hlist_add_head(&x->bysrc, xfrm_state_bysrc+h); 626 hlist_add_head(&x->bysrc, xfrm_state_bysrc+h);
624 627
625 if (xfrm_id_proto_match(x->id.proto, IPSEC_PROTO_ANY)) { 628 if (x->id.spi) {
626 h = xfrm_spi_hash(&x->id.daddr, x->id.spi, x->id.proto, 629 h = xfrm_spi_hash(&x->id.daddr, x->id.spi, x->id.proto,
627 x->props.family); 630 x->props.family);
628 631
@@ -916,7 +919,7 @@ err:
916EXPORT_SYMBOL(xfrm_state_check); 919EXPORT_SYMBOL(xfrm_state_check);
917 920
918struct xfrm_state * 921struct xfrm_state *
919xfrm_state_lookup(xfrm_address_t *daddr, u32 spi, u8 proto, 922xfrm_state_lookup(xfrm_address_t *daddr, __be32 spi, u8 proto,
920 unsigned short family) 923 unsigned short family)
921{ 924{
922 struct xfrm_state *x; 925 struct xfrm_state *x;
@@ -1040,7 +1043,7 @@ u32 xfrm_get_acqseq(void)
1040EXPORT_SYMBOL(xfrm_get_acqseq); 1043EXPORT_SYMBOL(xfrm_get_acqseq);
1041 1044
1042void 1045void
1043xfrm_alloc_spi(struct xfrm_state *x, u32 minspi, u32 maxspi) 1046xfrm_alloc_spi(struct xfrm_state *x, __be32 minspi, __be32 maxspi)
1044{ 1047{
1045 unsigned int h; 1048 unsigned int h;
1046 struct xfrm_state *x0; 1049 struct xfrm_state *x0;
@@ -1057,10 +1060,10 @@ xfrm_alloc_spi(struct xfrm_state *x, u32 minspi, u32 maxspi)
1057 x->id.spi = minspi; 1060 x->id.spi = minspi;
1058 } else { 1061 } else {
1059 u32 spi = 0; 1062 u32 spi = 0;
1060 minspi = ntohl(minspi); 1063 u32 low = ntohl(minspi);
1061 maxspi = ntohl(maxspi); 1064 u32 high = ntohl(maxspi);
1062 for (h=0; h<maxspi-minspi+1; h++) { 1065 for (h=0; h<high-low+1; h++) {
1063 spi = minspi + net_random()%(maxspi-minspi+1); 1066 spi = low + net_random()%(high-low+1);
1064 x0 = xfrm_state_lookup(&x->id.daddr, htonl(spi), x->id.proto, x->props.family); 1067 x0 = xfrm_state_lookup(&x->id.daddr, htonl(spi), x->id.proto, x->props.family);
1065 if (x0 == NULL) { 1068 if (x0 == NULL) {
1066 x->id.spi = htonl(spi); 1069 x->id.spi = htonl(spi);
@@ -1180,11 +1183,10 @@ static void xfrm_replay_timer_handler(unsigned long data)
1180 spin_unlock(&x->lock); 1183 spin_unlock(&x->lock);
1181} 1184}
1182 1185
1183int xfrm_replay_check(struct xfrm_state *x, u32 seq) 1186int xfrm_replay_check(struct xfrm_state *x, __be32 net_seq)
1184{ 1187{
1185 u32 diff; 1188 u32 diff;
1186 1189 u32 seq = ntohl(net_seq);
1187 seq = ntohl(seq);
1188 1190
1189 if (unlikely(seq == 0)) 1191 if (unlikely(seq == 0))
1190 return -EINVAL; 1192 return -EINVAL;
@@ -1206,11 +1208,10 @@ int xfrm_replay_check(struct xfrm_state *x, u32 seq)
1206} 1208}
1207EXPORT_SYMBOL(xfrm_replay_check); 1209EXPORT_SYMBOL(xfrm_replay_check);
1208 1210
1209void xfrm_replay_advance(struct xfrm_state *x, u32 seq) 1211void xfrm_replay_advance(struct xfrm_state *x, __be32 net_seq)
1210{ 1212{
1211 u32 diff; 1213 u32 diff;
1212 1214 u32 seq = ntohl(net_seq);
1213 seq = ntohl(seq);
1214 1215
1215 if (seq > x->replay.seq) { 1216 if (seq > x->replay.seq) {
1216 diff = seq - x->replay.seq; 1217 diff = seq - x->replay.seq;