From nobody Mon Sep 17 00:00:00 2001 Subject: [PATCH] appletalk endianness annotations From: Al Viro Date: 1136450735 -0500 Signed-off-by: Al Viro --- drivers/net/appletalk/ipddp.c | 5 +-- include/linux/atalk.h | 40 +-------------------- net/appletalk/ddp.c | 79 +++++++++++++++-------------------------- 3 files changed, 30 insertions(+), 94 deletions(-) 0b3d7ac02a78eaff6f0448cfd71bdaecf0c4ef9b diff --git a/drivers/net/appletalk/ipddp.c b/drivers/net/appletalk/ipddp.c index 1a44a79..afa5333 100644 --- a/drivers/net/appletalk/ipddp.c +++ b/drivers/net/appletalk/ipddp.c @@ -146,9 +146,7 @@ static int ipddp_xmit(struct sk_buff *sk /* Create the Extended DDP header */ ddp = (struct ddpehdr *)skb->data; - ddp->deh_len = skb->len; - ddp->deh_hops = 1; - ddp->deh_pad = 0; + ddp->deh_len_hops = htons(skb->len + (1<<10)); ddp->deh_sum = 0; /* @@ -171,7 +169,6 @@ static int ipddp_xmit(struct sk_buff *sk ddp->deh_sport = 72; *((__u8 *)(ddp+1)) = 22; /* ddp type = IP */ - *((__u16 *)ddp)=ntohs(*((__u16 *)ddp)); /* fix up length field */ skb->protocol = htons(ETH_P_ATALK); /* Protocol has changed */ diff --git a/include/linux/atalk.h b/include/linux/atalk.h index 911c09c..d60913f 100644 --- a/include/linux/atalk.h +++ b/include/linux/atalk.h @@ -88,15 +88,7 @@ static inline struct atalk_sock *at_sk(s #include struct ddpehdr { -#ifdef __LITTLE_ENDIAN_BITFIELD - __u16 deh_len:10, - deh_hops:4, - deh_pad:2; -#else - __u16 deh_pad:2, - deh_hops:4, - deh_len:10; -#endif + __be16 deh_len_hops; /* lower 10 bits are length, next 4 - hops */ __be16 deh_sum; __be16 deh_dnet; __be16 deh_snet; @@ -112,36 +104,6 @@ static __inline__ struct ddpehdr *ddp_hd return (struct ddpehdr *)skb->h.raw; } -/* - * Don't drop the struct into the struct above. You'll get some - * surprise padding. - */ -struct ddpebits { -#ifdef __LITTLE_ENDIAN_BITFIELD - __u16 deh_len:10, - deh_hops:4, - deh_pad:2; -#else - __u16 deh_pad:2, - deh_hops:4, - deh_len:10; -#endif -}; - -/* Short form header */ -struct ddpshdr { -#ifdef __LITTLE_ENDIAN_BITFIELD - __u16 dsh_len:10, - dsh_pad:6; -#else - __u16 dsh_pad:6, - dsh_len:10; -#endif - __u8 dsh_dport; - __u8 dsh_sport; - /* And netatalk apps expect to stick the type in themselves */ -}; - /* AppleTalk AARP headers */ struct elapaarp { __be16 hw_type; diff --git a/net/appletalk/ddp.c b/net/appletalk/ddp.c index 7982656..d8e7e41 100644 --- a/net/appletalk/ddp.c +++ b/net/appletalk/ddp.c @@ -1004,7 +1004,7 @@ static unsigned long atalk_sum_skb(const return sum; } -static unsigned short atalk_checksum(const struct sk_buff *skb, int len) +static __be16 atalk_checksum(const struct sk_buff *skb, int len) { unsigned long sum; @@ -1012,7 +1012,7 @@ static unsigned short atalk_checksum(con sum = atalk_sum_skb(skb, 4, len-4, 0); /* Use 0xFFFF for 0. 0 itself means none */ - return sum ? htons((unsigned short)sum) : 0xFFFF; + return sum ? htons((unsigned short)sum) : htons(0xFFFF); } static struct proto ddp_proto = { @@ -1291,7 +1291,7 @@ static int handle_ip_over_ddp(struct sk_ #endif static void atalk_route_packet(struct sk_buff *skb, struct net_device *dev, - struct ddpehdr *ddp, struct ddpebits *ddphv, + struct ddpehdr *ddp, __u16 len_hops, int origlen) { struct atalk_route *rt; @@ -1319,10 +1319,12 @@ static void atalk_route_packet(struct sk /* Route the packet */ rt = atrtr_find(&ta); - if (!rt || ddphv->deh_hops == DDP_MAXHOPS) + /* increment hops count */ + len_hops += 1 << 10; + if (!rt || !(len_hops & (15 << 10))) goto free_it; + /* FIXME: use skb->cb to be able to use shared skbs */ - ddphv->deh_hops++; /* * Route goes through another gateway, so set the target to the @@ -1337,11 +1339,10 @@ static void atalk_route_packet(struct sk /* Fix up skb->len field */ skb_trim(skb, min_t(unsigned int, origlen, (rt->dev->hard_header_len + - ddp_dl->header_length + ddphv->deh_len))); + ddp_dl->header_length + (len_hops & 1023)))); - /* Mend the byte order */ /* FIXME: use skb->cb to be able to use shared skbs */ - *((__u16 *)ddp) = ntohs(*((__u16 *)ddphv)); + ddp->deh_len_hops = htons(len_hops); /* * Send the buffer onwards @@ -1396,7 +1397,7 @@ static int atalk_rcv(struct sk_buff *skb struct atalk_iface *atif; struct sockaddr_at tosat; int origlen; - struct ddpebits ddphv; + __u16 len_hops; /* Don't mangle buffer if shared */ if (!(skb = skb_share_check(skb, GFP_ATOMIC))) @@ -1408,16 +1409,11 @@ static int atalk_rcv(struct sk_buff *skb ddp = ddp_hdr(skb); - /* - * Fix up the length field [Ok this is horrible but otherwise - * I end up with unions of bit fields and messy bit field order - * compiler/endian dependencies..] - */ - *((__u16 *)&ddphv) = ntohs(*((__u16 *)ddp)); + len_hops = ntohs(ddp->deh_len_hops); /* Trim buffer in case of stray trailing data */ origlen = skb->len; - skb_trim(skb, min_t(unsigned int, skb->len, ddphv.deh_len)); + skb_trim(skb, min_t(unsigned int, skb->len, len_hops & 1023)); /* * Size check to see if ddp->deh_len was crap @@ -1432,7 +1428,7 @@ static int atalk_rcv(struct sk_buff *skb * valid for net byte orders all over the networking code... */ if (ddp->deh_sum && - atalk_checksum(skb, ddphv.deh_len) != ddp->deh_sum) + atalk_checksum(skb, len_hops & 1023) != ddp->deh_sum) /* Not a valid AppleTalk frame - dustbin time */ goto freeit; @@ -1446,7 +1442,7 @@ static int atalk_rcv(struct sk_buff *skb /* Not ours, so we route the packet via the correct * AppleTalk iface */ - atalk_route_packet(skb, dev, ddp, &ddphv, origlen); + atalk_route_packet(skb, dev, ddp, len_hops, origlen); goto out; } @@ -1491,7 +1487,7 @@ static int ltalk_rcv(struct sk_buff *skb /* Find our address */ struct atalk_addr *ap = atalk_find_dev_addr(dev); - if (!ap || skb->len < sizeof(struct ddpshdr)) + if (!ap || skb->len < sizeof(__be16) || skb->len > 1023) goto freeit; /* Don't mangle buffer if shared */ @@ -1521,11 +1517,8 @@ static int ltalk_rcv(struct sk_buff *skb /* * Not sure about this bit... */ - ddp->deh_len = skb->len; - ddp->deh_hops = DDP_MAXHOPS; /* Non routable, so force a drop - if we slip up later */ - /* Mend the byte order */ - *((__u16 *)ddp) = htons(*((__u16 *)ddp)); + /* Non routable, so force a drop if we slip up later */ + ddp->deh_len_hops = htons(skb->len + (DDP_MAXHOPS << 10)); } skb->h.raw = skb->data; @@ -1624,16 +1617,7 @@ static int atalk_sendmsg(struct kiocb *i SOCK_DEBUG(sk, "SK %p: Begin build.\n", sk); ddp = (struct ddpehdr *)skb_put(skb, sizeof(struct ddpehdr)); - ddp->deh_pad = 0; - ddp->deh_hops = 0; - ddp->deh_len = len + sizeof(*ddp); - /* - * Fix up the length field [Ok this is horrible but otherwise - * I end up with unions of bit fields and messy bit field order - * compiler/endian dependencies.. - */ - *((__u16 *)ddp) = ntohs(*((__u16 *)ddp)); - + ddp->deh_len_hops = htons(len + sizeof(*ddp)); ddp->deh_dnet = usat->sat_addr.s_net; ddp->deh_snet = at->src_net; ddp->deh_dnode = usat->sat_addr.s_node; @@ -1714,8 +1698,8 @@ static int atalk_recvmsg(struct kiocb *i struct sockaddr_at *sat = (struct sockaddr_at *)msg->msg_name; struct ddpehdr *ddp; int copied = 0; + int offset = 0; int err = 0; - struct ddpebits ddphv; struct sk_buff *skb = skb_recv_datagram(sk, flags & ~MSG_DONTWAIT, flags & MSG_DONTWAIT, &err); if (!skb) @@ -1723,25 +1707,18 @@ static int atalk_recvmsg(struct kiocb *i /* FIXME: use skb->cb to be able to use shared skbs */ ddp = ddp_hdr(skb); - *((__u16 *)&ddphv) = ntohs(*((__u16 *)ddp)); + copied = ntohs(ddp->deh_len_hops) & 1023; - if (sk->sk_type == SOCK_RAW) { - copied = ddphv.deh_len; - if (copied > size) { - copied = size; - msg->msg_flags |= MSG_TRUNC; - } + if (sk->sk_type != SOCK_RAW) { + offset = sizeof(*ddp); + copied -= offset; + } - err = skb_copy_datagram_iovec(skb, 0, msg->msg_iov, copied); - } else { - copied = ddphv.deh_len - sizeof(*ddp); - if (copied > size) { - copied = size; - msg->msg_flags |= MSG_TRUNC; - } - err = skb_copy_datagram_iovec(skb, sizeof(*ddp), - msg->msg_iov, copied); + if (copied > size) { + copied = size; + msg->msg_flags |= MSG_TRUNC; } + err = skb_copy_datagram_iovec(skb, offset, msg->msg_iov, copied); if (!err) { if (sat) { -- 0.99.9.GIT From nobody Mon Sep 17 00:00:00 2001 Subject: [PATCH] trdev endiannness annotations From: Al Viro Date: 1136450816 -0500 Signed-off-by: Al Viro --- include/linux/trdevice.h | 2 +- net/802/tr.c | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) 84f28e6b9ff51e95edf7edcf8b7a1e6000af25cf diff --git a/include/linux/trdevice.h b/include/linux/trdevice.h index 99e02ef..bfc84a7 100644 --- a/include/linux/trdevice.h +++ b/include/linux/trdevice.h @@ -28,7 +28,7 @@ #include #ifdef __KERNEL__ -extern unsigned short tr_type_trans(struct sk_buff *skb, struct net_device *dev); +extern __be16 tr_type_trans(struct sk_buff *skb, struct net_device *dev); extern void tr_source_route(struct sk_buff *skb, struct trh_hdr *trh, struct net_device *dev); extern struct net_device *alloc_trdev(int sizeof_priv); diff --git a/net/802/tr.c b/net/802/tr.c index afd8385..b329bbf 100644 --- a/net/802/tr.c +++ b/net/802/tr.c @@ -165,7 +165,7 @@ static int tr_rebuild_header(struct sk_b */ if(trllc->ethertype != htons(ETH_P_IP)) { - printk("tr_rebuild_header: Don't know how to resolve type %04X addresses ?\n",(unsigned int)htons(trllc->ethertype)); + printk("tr_rebuild_header: Don't know how to resolve type %04X addresses ?\n", ntohs(trllc->ethertype)); return 0; } @@ -187,7 +187,7 @@ static int tr_rebuild_header(struct sk_b * it via SNAP. */ -unsigned short tr_type_trans(struct sk_buff *skb, struct net_device *dev) +__be16 tr_type_trans(struct sk_buff *skb, struct net_device *dev) { struct trh_hdr *trh=(struct trh_hdr *)skb->data; @@ -230,15 +230,15 @@ unsigned short tr_type_trans(struct sk_b */ if (trllc->dsap == EXTENDED_SAP && - (trllc->ethertype == ntohs(ETH_P_IP) || - trllc->ethertype == ntohs(ETH_P_IPV6) || - trllc->ethertype == ntohs(ETH_P_ARP))) + (trllc->ethertype == htons(ETH_P_IP) || + trllc->ethertype == htons(ETH_P_IPV6) || + trllc->ethertype == htons(ETH_P_ARP))) { skb_pull(skb, sizeof(struct trllc)); return trllc->ethertype; } - return ntohs(ETH_P_TR_802_2); + return htons(ETH_P_TR_802_2); } /* -- 0.99.9.GIT From nobody Mon Sep 17 00:00:00 2001 Subject: [PATCH] fix broken uses of NIPQUAD in net/atm From: Al Viro Date: 1136451289 -0500 NIPQUAD expects an l-value of type __be32, _NOT_ a pointer to __be32. Signed-off-by: Al Viro --- net/atm/mpc.c | 13 +++---------- net/atm/mpoa_caches.c | 12 ++++-------- 2 files changed, 7 insertions(+), 18 deletions(-) 15d582d1a92994aee6efa84575b9af83d5b137be diff --git a/net/atm/mpc.c b/net/atm/mpc.c index 526d953..00f561d 100644 --- a/net/atm/mpc.c +++ b/net/atm/mpc.c @@ -228,20 +228,15 @@ int atm_mpoa_delete_qos(struct atm_mpoa_ /* this is buggered - we need locking for qos_head */ void atm_mpoa_disp_qos(struct seq_file *m) { - unsigned char *ip; - char ipaddr[16]; struct atm_mpoa_qos *qos; qos = qos_head; seq_printf(m, "QoS entries for shortcuts:\n"); seq_printf(m, "IP address\n TX:max_pcr pcr min_pcr max_cdv max_sdu\n RX:max_pcr pcr min_pcr max_cdv max_sdu\n"); - ipaddr[sizeof(ipaddr)-1] = '\0'; while (qos != NULL) { - ip = (unsigned char *)&qos->ipaddr; - sprintf(ipaddr, "%u.%u.%u.%u", NIPQUAD(ip)); seq_printf(m, "%u.%u.%u.%u\n %-7d %-7d %-7d %-7d %-7d\n %-7d %-7d %-7d %-7d %-7d\n", - NIPQUAD(ipaddr), + NIPQUAD(qos->ipaddr), qos->qos.txtp.max_pcr, qos->qos.txtp.pcr, qos->qos.txtp.min_pcr, qos->qos.txtp.max_cdv, qos->qos.txtp.max_sdu, qos->qos.rxtp.max_pcr, qos->qos.rxtp.pcr, qos->qos.rxtp.min_pcr, qos->qos.rxtp.max_cdv, qos->qos.rxtp.max_sdu); qos = qos->next; @@ -1082,7 +1077,6 @@ static void MPOA_trigger_rcvd(struct k_m static void check_qos_and_open_shortcut(struct k_message *msg, struct mpoa_client *client, in_cache_entry *entry) { uint32_t dst_ip = msg->content.in_info.in_dst_ip; - unsigned char *ip __attribute__ ((unused)) = (unsigned char *)&dst_ip; struct atm_mpoa_qos *qos = atm_mpoa_search_qos(dst_ip); eg_cache_entry *eg_entry = client->eg_ops->get_by_src_ip(dst_ip, client); @@ -1096,7 +1090,7 @@ static void check_qos_and_open_shortcut( entry->shortcut = eg_entry->shortcut; } if(entry->shortcut){ - dprintk("mpoa: (%s) using egress SVC to reach %u.%u.%u.%u\n",client->dev->name, NIPQUAD(ip)); + dprintk("mpoa: (%s) using egress SVC to reach %u.%u.%u.%u\n",client->dev->name, NIPQUAD(dst_ip)); client->eg_ops->put(eg_entry); return; } @@ -1122,8 +1116,7 @@ static void MPOA_res_reply_rcvd(struct k uint32_t dst_ip = msg->content.in_info.in_dst_ip; in_cache_entry *entry = mpc->in_ops->get(dst_ip, mpc); - ip = (unsigned char *)&dst_ip; - dprintk("mpoa: (%s) MPOA_res_reply_rcvd: ip %u.%u.%u.%u\n", mpc->dev->name, NIPQUAD(ip)); + dprintk("mpoa: (%s) MPOA_res_reply_rcvd: ip %u.%u.%u.%u\n", mpc->dev->name, NIPQUAD(dst_ip)); ddprintk("mpoa: (%s) MPOA_res_reply_rcvd() entry = %p", mpc->dev->name, entry); if(entry == NULL){ printk("\nmpoa: (%s) ARGH, received res. reply for an entry that doesn't exist.\n", mpc->dev->name); diff --git a/net/atm/mpoa_caches.c b/net/atm/mpoa_caches.c index 64ddebb..781ed1b 100644 --- a/net/atm/mpoa_caches.c +++ b/net/atm/mpoa_caches.c @@ -223,7 +223,6 @@ static void in_cache_remove_entry(in_cac but an easy one... */ static void clear_count_and_expired(struct mpoa_client *client) { - unsigned char *ip; in_cache_entry *entry, *next_entry; struct timeval now; @@ -236,8 +235,7 @@ static void clear_count_and_expired(stru next_entry = entry->next; if((now.tv_sec - entry->tv.tv_sec) > entry->ctrl_info.holding_time){ - ip = (unsigned char*)&entry->ctrl_info.in_dst_ip; - dprintk("mpoa: mpoa_caches.c: holding time expired, ip = %u.%u.%u.%u\n", NIPQUAD(ip)); + dprintk("mpoa: mpoa_caches.c: holding time expired, ip = %u.%u.%u.%u\n", NIPQUAD(entry->ctrl_info.in_dst_ip)); client->in_ops->remove_entry(entry, client); } entry = next_entry; @@ -455,7 +453,6 @@ static void eg_cache_remove_entry(eg_cac static eg_cache_entry *eg_cache_add_entry(struct k_message *msg, struct mpoa_client *client) { - unsigned char *ip; eg_cache_entry *entry = kmalloc(sizeof(eg_cache_entry), GFP_KERNEL); if (entry == NULL) { @@ -463,8 +460,7 @@ static eg_cache_entry *eg_cache_add_entr return NULL; } - ip = (unsigned char *)&msg->content.eg_info.eg_dst_ip; - dprintk("mpoa: mpoa_caches.c: adding an egress entry, ip = %u.%u.%u.%u, this should be our IP\n", NIPQUAD(ip)); + dprintk("mpoa: mpoa_caches.c: adding an egress entry, ip = %u.%u.%u.%u, this should be our IP\n", NIPQUAD(msg->content.eg_info.eg_dst_ip)); memset(entry, 0, sizeof(eg_cache_entry)); atomic_set(&entry->use, 1); @@ -481,8 +477,8 @@ static eg_cache_entry *eg_cache_add_entr do_gettimeofday(&(entry->tv)); entry->entry_state = EGRESS_RESOLVED; dprintk("mpoa: mpoa_caches.c: new_eg_cache_entry cache_id %lu\n", ntohl(entry->ctrl_info.cache_id)); - ip = (unsigned char *)&entry->ctrl_info.mps_ip; - dprintk("mpoa: mpoa_caches.c: mps_ip = %u.%u.%u.%u\n", NIPQUAD(ip)); + dprintk("mpoa: mpoa_caches.c: mps_ip = %u.%u.%u.%u\n", + NIPQUAD(entry->ctrl_info.mps_ip)); atomic_inc(&entry->use); write_unlock_irq(&client->egress_lock); -- 0.99.9.GIT From nobody Mon Sep 17 00:00:00 2001 Subject: [PATCH] net/atm/*: use NIPQUAD instead of open-coding it From: Al Viro Date: 1136451732 -0500 Signed-off-by: Al Viro --- net/atm/mpc.c | 15 ++++----------- net/atm/mpoa_caches.c | 12 +++--------- 2 files changed, 7 insertions(+), 20 deletions(-) 46f7b980b2d7eb9740db03fe8ddc00125cf63bd5 diff --git a/net/atm/mpc.c b/net/atm/mpc.c index 00f561d..f79b799 100644 --- a/net/atm/mpc.c +++ b/net/atm/mpc.c @@ -566,7 +566,6 @@ static int atm_mpoa_vcc_attach(struct at struct atmmpc_ioc ioc_data; in_cache_entry *in_entry; uint32_t ipaddr; - unsigned char *ip; bytes_left = copy_from_user(&ioc_data, arg, sizeof(struct atmmpc_ioc)); if (bytes_left != 0) { @@ -589,9 +588,8 @@ static int atm_mpoa_vcc_attach(struct at if (in_entry != NULL) mpc->in_ops->put(in_entry); return -EINVAL; } - ip = (unsigned char*)&in_entry->ctrl_info.in_dst_ip; printk("mpoa: (%s) mpc_vcc_attach: attaching ingress SVC, entry = %u.%u.%u.%u\n", - mpc->dev->name, ip[0], ip[1], ip[2], ip[3]); + mpc->dev->name, NIPQUAD(in_entry->ctrl_info.in_dst_ip)); in_entry->shortcut = vcc; mpc->in_ops->put(in_entry); } else { @@ -622,10 +620,8 @@ static void mpc_vcc_close(struct atm_vcc dprintk("mpoa: (%s) mpc_vcc_close:\n", dev->name); in_entry = mpc->in_ops->get_by_vcc(vcc, mpc); if (in_entry) { - unsigned char *ip __attribute__ ((unused)) = - (unsigned char *)&in_entry->ctrl_info.in_dst_ip; dprintk("mpoa: (%s) mpc_vcc_close: ingress SVC closed ip = %u.%u.%u.%u\n", - mpc->dev->name, ip[0], ip[1], ip[2], ip[3]); + mpc->dev->name, NIPQUAD(in_entry->ctrl_info.in_dst_ip)); in_entry->shortcut = NULL; mpc->in_ops->put(in_entry); } @@ -1112,8 +1108,6 @@ static void check_qos_and_open_shortcut( static void MPOA_res_reply_rcvd(struct k_message *msg, struct mpoa_client *mpc) { - unsigned char *ip; - uint32_t dst_ip = msg->content.in_info.in_dst_ip; in_cache_entry *entry = mpc->in_ops->get(dst_ip, mpc); dprintk("mpoa: (%s) MPOA_res_reply_rcvd: ip %u.%u.%u.%u\n", mpc->dev->name, NIPQUAD(dst_ip)); @@ -1161,18 +1155,17 @@ static void ingress_purge_rcvd(struct k_ { uint32_t dst_ip = msg->content.in_info.in_dst_ip; uint32_t mask = msg->ip_mask; - unsigned char *ip = (unsigned char *)&dst_ip; in_cache_entry *entry = mpc->in_ops->get_with_mask(dst_ip, mpc, mask); if(entry == NULL){ printk("mpoa: (%s) ingress_purge_rcvd: purge for a non-existing entry, ", mpc->dev->name); - printk("ip = %u.%u.%u.%u\n", ip[0], ip[1], ip[2], ip[3]); + printk("ip = %u.%u.%u.%u\n", NIPQUAD(dst_ip)); return; } do { dprintk("mpoa: (%s) ingress_purge_rcvd: removing an ingress entry, ip = %u.%u.%u.%u\n" , - mpc->dev->name, ip[0], ip[1], ip[2], ip[3]); + mpc->dev->name, NIPQUAD(dst_ip)); write_lock_bh(&mpc->ingress_lock); mpc->in_ops->remove_entry(entry, mpc); write_unlock_bh(&mpc->ingress_lock); diff --git a/net/atm/mpoa_caches.c b/net/atm/mpoa_caches.c index 781ed1b..fbf13cd 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_v static in_cache_entry *in_cache_add_entry(uint32_t dst_ip, struct mpoa_client *client) { - unsigned char *ip __attribute__ ((unused)) = (unsigned char *)&dst_ip; in_cache_entry* entry = kmalloc(sizeof(in_cache_entry), GFP_KERNEL); if (entry == NULL) { @@ -95,7 +94,7 @@ static in_cache_entry *in_cache_add_entr return NULL; } - dprintk("mpoa: mpoa_caches.c: adding an ingress entry, ip = %u.%u.%u.%u\n", ip[0], ip[1], ip[2], ip[3]); + dprintk("mpoa: mpoa_caches.c: adding an ingress entry, ip = %u.%u.%u.%u\n", NIPQUAD(dst_ip)); memset(entry,0,sizeof(in_cache_entry)); atomic_set(&entry->use, 1); @@ -152,10 +151,7 @@ static int cache_hit(in_cache_entry *ent if( entry->count > mpc->parameters.mpc_p1 && entry->entry_state == INGRESS_INVALID){ - unsigned char *ip __attribute__ ((unused)) = - (unsigned char *)&entry->ctrl_info.in_dst_ip; - - 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]); + 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)); entry->entry_state = INGRESS_RESOLVING; msg.type = SND_MPOA_RES_RQST; memcpy(msg.MPS_ctrl, mpc->mps_ctrl_addr, ATM_ESA_LEN ); @@ -187,11 +183,9 @@ static void in_cache_remove_entry(in_cac { struct atm_vcc *vcc; struct k_message msg; - unsigned char *ip; vcc = entry->shortcut; - ip = (unsigned char *)&entry->ctrl_info.in_dst_ip; - dprintk("mpoa: mpoa_caches.c: removing an ingress entry, ip = %u.%u.%u.%u\n",ip[0], ip[1], ip[2], ip[3]); + dprintk("mpoa: mpoa_caches.c: removing an ingress entry, ip = %u.%u.%u.%u\n",NIPQUAD(entry->ctrl_info.in_dst_ip)); if (entry->prev != NULL) entry->prev->next = entry->next; -- 0.99.9.GIT From nobody Mon Sep 17 00:00:00 2001 Subject: [PATCH] in_addr is big-endian From: Al Viro Date: 1136462450 -0500 --- include/linux/in.h | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) fe8a770ad3eceb97ab8d45b2229ce1d3536cf7f6 diff --git a/include/linux/in.h b/include/linux/in.h index ba35538..2d22686 100644 --- a/include/linux/in.h +++ b/include/linux/in.h @@ -52,7 +52,7 @@ enum { /* Internet address. */ struct in_addr { - __u32 s_addr; + __be32 s_addr; }; #define IP_TOS 1 -- 0.99.9.GIT From nobody Mon Sep 17 00:00:00 2001 Subject: [PATCH] ipv4 headers endianness From: Al Viro Date: 1136463196 -0500 --- include/linux/ip.h | 24 ++++++++++++------------ 1 files changed, 12 insertions(+), 12 deletions(-) 22ace9e1e89deae81930aa93e5d976f17ec8e517 diff --git a/include/linux/ip.h b/include/linux/ip.h index 33e8a19..68c22c3 100644 --- a/include/linux/ip.h +++ b/include/linux/ip.h @@ -209,36 +209,36 @@ struct iphdr { #error "Please fix " #endif __u8 tos; - __u16 tot_len; - __u16 id; - __u16 frag_off; + __be16 tot_len; + __be16 id; + __be16 frag_off; __u8 ttl; __u8 protocol; - __u16 check; - __u32 saddr; - __u32 daddr; + __be16 check; + __be32 saddr; + __be32 daddr; /*The options start here. */ }; struct ip_auth_hdr { __u8 nexthdr; __u8 hdrlen; /* This one is measured in 32 bit units! */ - __u16 reserved; - __u32 spi; - __u32 seq_no; /* Sequence number */ + __be16 reserved; + __be32 spi; + __be32 seq_no; /* Sequence number */ __u8 auth_data[0]; /* Variable len but >=4. Mind the 64 bit alignment! */ }; struct ip_esp_hdr { - __u32 spi; - __u32 seq_no; /* Sequence number */ + __be32 spi; + __be32 seq_no; /* Sequence number */ __u8 enc_data[0]; /* Variable len but >=8. Mind the 64 bit alignment! */ }; struct ip_comp_hdr { __u8 nexthdr; __u8 flags; - __u16 cpi; + __be16 cpi; }; #endif /* _LINUX_IP_H */ -- 0.99.9.GIT From nobody Mon Sep 17 00:00:00 2001 Subject: [PATCH] ip_route_input() endianness From: Al Viro Date: 1136464318 -0500 --- include/net/route.h | 2 +- net/ipv4/arp.c | 2 +- net/ipv4/ip_options.c | 2 +- net/ipv4/route.c | 6 +++--- 4 files changed, 6 insertions(+), 6 deletions(-) ff708bf04c8dbf09fdf1003ba01dbbca235329d2 diff --git a/include/net/route.h b/include/net/route.h index e3e5436..15d5cb6 100644 --- a/include/net/route.h +++ b/include/net/route.h @@ -116,7 +116,7 @@ extern void rt_cache_flush(int how); extern int __ip_route_output_key(struct rtable **, const struct flowi *flp); extern int ip_route_output_key(struct rtable **, struct flowi *flp); extern int ip_route_output_flow(struct rtable **rp, struct flowi *flp, struct sock *sk, int flags); -extern int ip_route_input(struct sk_buff*, u32 dst, u32 src, u8 tos, struct net_device *devin); +extern int ip_route_input(struct sk_buff*, __be32 dst, __be32 src, u8 tos, struct net_device *devin); extern unsigned short ip_rt_frag_needed(struct iphdr *iph, unsigned short new_mtu); extern void ip_rt_send_redirect(struct sk_buff *skb); diff --git a/net/ipv4/arp.c b/net/ipv4/arp.c index b425748..ae27a70 100644 --- a/net/ipv4/arp.c +++ b/net/ipv4/arp.c @@ -709,7 +709,7 @@ static int arp_process(struct sk_buff *s unsigned char *arp_ptr; struct rtable *rt; unsigned char *sha, *tha; - u32 sip, tip; + __be32 sip, tip; u16 dev_type = dev->type; int addr_type; struct neighbour *n; diff --git a/net/ipv4/ip_options.c b/net/ipv4/ip_options.c index dbe12da..cd894ec 100644 --- a/net/ipv4/ip_options.c +++ b/net/ipv4/ip_options.c @@ -588,7 +588,7 @@ int ip_options_rcv_srr(struct sk_buff *s { struct ip_options *opt = &(IPCB(skb)->opt); int srrspace, srrptr; - u32 nexthop; + __be32 nexthop; struct iphdr *iph = skb->nh.iph; unsigned char * optptr = skb->nh.raw + opt->srr; struct rtable *rt = (struct rtable*)skb->dst; diff --git a/net/ipv4/route.c b/net/ipv4/route.c index f701a13..467300c 100644 --- a/net/ipv4/route.c +++ b/net/ipv4/route.c @@ -2080,7 +2080,7 @@ martian_source: goto e_inval; } -int ip_route_input(struct sk_buff *skb, u32 daddr, u32 saddr, +int ip_route_input(struct sk_buff *skb, __be32 daddr, __be32 saddr, u8 tos, struct net_device *dev) { struct rtable * rth; @@ -2737,8 +2737,8 @@ int inet_rtm_getroute(struct sk_buff *in struct rtattr **rta = arg; struct rtmsg *rtm = NLMSG_DATA(nlh); struct rtable *rt = NULL; - u32 dst = 0; - u32 src = 0; + __be32 dst = 0; + __be32 src = 0; int iif = 0; int err = -ENOBUFS; struct sk_buff *skb; -- 0.99.9.GIT From nobody Mon Sep 17 00:00:00 2001 Subject: [PATCH] ipv4/route.c: propagating endianness annotations From: Al Viro Date: 1136465053 -0500 --- net/ipv4/route.c | 14 +++++++------- 1 files changed, 7 insertions(+), 7 deletions(-) 3aaf876e76807bc7f523c899b9d0728a1eaf296c diff --git a/net/ipv4/route.c b/net/ipv4/route.c index 467300c..706ca17 100644 --- a/net/ipv4/route.c +++ b/net/ipv4/route.c @@ -1589,7 +1589,7 @@ static void rt_set_nexthop(struct rtable rt->rt_type = res->type; } -static int ip_route_input_mc(struct sk_buff *skb, u32 daddr, u32 saddr, +static int ip_route_input_mc(struct sk_buff *skb, __be32 daddr, __be32 saddr, u8 tos, struct net_device *dev, int our) { unsigned hash; @@ -1674,8 +1674,8 @@ e_inval: static void ip_handle_martian_source(struct net_device *dev, struct in_device *in_dev, struct sk_buff *skb, - u32 daddr, - u32 saddr) + __be32 daddr, + __be32 saddr) { RT_CACHE_STAT_INC(in_martian_src); #ifdef CONFIG_IP_ROUTE_VERBOSE @@ -1705,7 +1705,7 @@ static void ip_handle_martian_source(str static inline int __mkroute_input(struct sk_buff *skb, struct fib_result* res, struct in_device *in_dev, - u32 daddr, u32 saddr, u32 tos, + __be32 daddr, __be32 saddr, u32 tos, struct rtable **result) { @@ -1806,7 +1806,7 @@ static inline int ip_mkroute_input_def(s struct fib_result* res, const struct flowi *fl, struct in_device *in_dev, - u32 daddr, u32 saddr, u32 tos) + __be32 daddr, __be32 saddr, u32 tos) { struct rtable* rth = NULL; int err; @@ -1831,7 +1831,7 @@ static inline int ip_mkroute_input(struc struct fib_result* res, const struct flowi *fl, struct in_device *in_dev, - u32 daddr, u32 saddr, u32 tos) + __be32 daddr, __be32 saddr, u32 tos) { #ifdef CONFIG_IP_ROUTE_MULTIPATH_CACHED struct rtable* rth = NULL, *rtres; @@ -1894,7 +1894,7 @@ static inline int ip_mkroute_input(struc * 2. IP spoofing attempts are filtered with 100% of guarantee. */ -static int ip_route_input_slow(struct sk_buff *skb, u32 daddr, u32 saddr, +static int ip_route_input_slow(struct sk_buff *skb, __be32 daddr, __be32 saddr, u8 tos, struct net_device *dev) { struct fib_result res; -- 0.99.9.GIT From nobody Mon Sep 17 00:00:00 2001 Subject: [PATCH] ip_rt_redirect() endianness From: Al Viro Date: 1136465856 -0500 --- include/net/route.h | 4 ++-- net/ipv4/route.c | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) 53eb4cb44a79bfe4233974ae09666df9c45e376b diff --git a/include/net/route.h b/include/net/route.h index 15d5cb6..5292047 100644 --- a/include/net/route.h +++ b/include/net/route.h @@ -109,8 +109,8 @@ extern struct ip_rt_acct *ip_rt_acct; struct in_device; extern int ip_rt_init(void); -extern void ip_rt_redirect(u32 old_gw, u32 dst, u32 new_gw, - u32 src, u8 tos, struct net_device *dev); +extern void ip_rt_redirect(__be32 old_gw, __be32 dst, __be32 new_gw, + __be32 src, u8 tos, struct net_device *dev); extern void ip_rt_advice(struct rtable **rp, int advice); extern void rt_cache_flush(int how); extern int __ip_route_output_key(struct rtable **, const struct flowi *flp); diff --git a/net/ipv4/route.c b/net/ipv4/route.c index 706ca17..b966d7a 100644 --- a/net/ipv4/route.c +++ b/net/ipv4/route.c @@ -1110,13 +1110,13 @@ static void rt_del(unsigned hash, struct spin_unlock_bh(rt_hash_lock_addr(hash)); } -void ip_rt_redirect(u32 old_gw, u32 daddr, u32 new_gw, - u32 saddr, u8 tos, struct net_device *dev) +void ip_rt_redirect(__be32 old_gw, __be32 daddr, __be32 new_gw, + __be32 saddr, u8 tos, struct net_device *dev) { int i, k; struct in_device *in_dev = in_dev_get(dev); struct rtable *rth, **rthp; - u32 skeys[2] = { saddr, 0 }; + __be32 skeys[2] = { saddr, 0 }; int ikeys[2] = { dev->ifindex, 0 }; tos &= IPTOS_RT_MASK; -- 0.99.9.GIT From nobody Mon Sep 17 00:00:00 2001 Subject: [PATCH] annotate ipv4 addresses in struct rtable and struct flowi From: Al Viro Date: 1136467747 -0500 --- include/net/flow.h | 4 ++-- include/net/route.h | 8 ++++---- net/ipv4/route.c | 16 ++++++++-------- 3 files changed, 14 insertions(+), 14 deletions(-) 33a311f8fcaafd04de686c6f5e87de65d3139844 diff --git a/include/net/flow.h b/include/net/flow.h index 9a5c94b..07d5d70 100644 --- a/include/net/flow.h +++ b/include/net/flow.h @@ -16,8 +16,8 @@ struct flowi { union { struct { - __u32 daddr; - __u32 saddr; + __be32 daddr; + __be32 saddr; __u32 fwmark; __u8 tos; __u8 scope; diff --git a/include/net/route.h b/include/net/route.h index 5292047..2e59e94 100644 --- a/include/net/route.h +++ b/include/net/route.h @@ -62,18 +62,18 @@ struct rtable __u16 rt_type; __u16 rt_multipath_alg; - __u32 rt_dst; /* Path destination */ - __u32 rt_src; /* Path source */ + __be32 rt_dst; /* Path destination */ + __be32 rt_src; /* Path source */ int rt_iif; /* Info on neighbour */ - __u32 rt_gateway; + __be32 rt_gateway; /* Cache lookup keys */ struct flowi fl; /* Miscellaneous cached information */ - __u32 rt_spec_dst; /* RFC1122 specific destination */ + __be32 rt_spec_dst; /* RFC1122 specific destination */ struct inet_peer *peer; /* long-living peer info */ }; diff --git a/net/ipv4/route.c b/net/ipv4/route.c index b966d7a..22eb191 100644 --- a/net/ipv4/route.c +++ b/net/ipv4/route.c @@ -1389,8 +1389,8 @@ unsigned short ip_rt_frag_needed(struct int i; unsigned short old_mtu = ntohs(iph->tot_len); struct rtable *rth; - u32 skeys[2] = { iph->saddr, 0, }; - u32 daddr = iph->daddr; + __be32 skeys[2] = { iph->saddr, 0, }; + __be32 daddr = iph->daddr; u8 tos = iph->tos & IPTOS_RT_MASK; unsigned short est_mtu = 0; @@ -1594,7 +1594,7 @@ static int ip_route_input_mc(struct sk_b { unsigned hash; struct rtable *rth; - u32 spec_dst; + __be32 spec_dst; struct in_device *in_dev = in_dev_get(dev); u32 itag = 0; @@ -1929,7 +1929,7 @@ static int ip_route_input_slow(struct sk if (MULTICAST(saddr) || BADCLASS(saddr) || LOOPBACK(saddr)) goto martian_source; - if (daddr == 0xFFFFFFFF || (saddr == 0 && daddr == 0)) + if (daddr == htonl(0xFFFFFFFF) || (saddr == 0 && daddr == 0)) goto brd_input; /* Accept zero addresses only to limited broadcast; @@ -2162,7 +2162,7 @@ static inline int __mkroute_output(struc if (LOOPBACK(fl->fl4_src) && !(dev_out->flags&IFF_LOOPBACK)) return -EINVAL; - if (fl->fl4_dst == 0xFFFFFFFF) + if (fl->fl4_dst == htonl(0xFFFFFFFF)) res->type = RTN_BROADCAST; else if (MULTICAST(fl->fl4_dst)) res->type = RTN_MULTICAST; @@ -2413,7 +2413,7 @@ static int ip_route_output_slow(struct r */ if (oldflp->oif == 0 - && (MULTICAST(oldflp->fl4_dst) || oldflp->fl4_dst == 0xFFFFFFFF)) { + && (MULTICAST(oldflp->fl4_dst) || oldflp->fl4_dst == htonl(0xFFFFFFFF))) { /* Special hack: user can direct multicasts and limited broadcast via necessary interface without fiddling with IP_MULTICAST_IF or IP_PKTINFO. @@ -2450,7 +2450,7 @@ static int ip_route_output_slow(struct r goto out; /* Wrong error code */ } - if (LOCAL_MCAST(oldflp->fl4_dst) || oldflp->fl4_dst == 0xFFFFFFFF) { + if (LOCAL_MCAST(oldflp->fl4_dst) || oldflp->fl4_dst == htonl(0xFFFFFFFF)) { if (!fl.fl4_src) fl.fl4_src = inet_select_addr(dev_out, 0, RT_SCOPE_LINK); @@ -2702,7 +2702,7 @@ static int rt_fill_info(struct sk_buff * RTA_PUT(skb, RTA_CACHEINFO, sizeof(ci), &ci); if (rt->fl.iif) { #ifdef CONFIG_IP_MROUTE - u32 dst = rt->rt_dst; + __be32 dst = rt->rt_dst; if (MULTICAST(dst) && !LOCAL_MCAST(dst) && ipv4_devconf.mc_forwarding) { -- 0.99.9.GIT From nobody Mon Sep 17 00:00:00 2001 Subject: [PATCH] annotate rt_hash_code() users From: Al Viro Date: 1136468531 -0500 --- net/ipv4/route.c | 37 ++++++++++++++++++------------------- 1 files changed, 18 insertions(+), 19 deletions(-) f1ab19c411f2cefdd3de701f720b4f7f949f6d70 diff --git a/net/ipv4/route.c b/net/ipv4/route.c index 22eb191..494a95b 100644 --- a/net/ipv4/route.c +++ b/net/ipv4/route.c @@ -253,6 +253,10 @@ static unsigned int rt_hash_code(u32 dad & rt_hash_mask); } +#define rt_hash(daddr, saddr, idx, tos) \ + rt_hash_code((__force u32)(__be32)(daddr),\ + (__force u32)(__be32)(saddr) ^ ((idx) << 5), (tos)) + #ifdef CONFIG_PROC_FS struct rt_cache_iter_state { int bucket; @@ -1140,9 +1144,7 @@ void ip_rt_redirect(__be32 old_gw, __be3 for (i = 0; i < 2; i++) { for (k = 0; k < 2; k++) { - unsigned hash = rt_hash_code(daddr, - skeys[i] ^ (ikeys[k] << 5), - tos); + unsigned hash = rt_hash(daddr, skeys[i], ikeys[k], tos); rthp=&rt_hash_table[hash].chain; @@ -1251,10 +1253,8 @@ static struct dst_entry *ipv4_negative_a ret = NULL; } else if ((rt->rt_flags & RTCF_REDIRECTED) || rt->u.dst.expires) { - unsigned hash = rt_hash_code(rt->fl.fl4_dst, - rt->fl.fl4_src ^ - (rt->fl.oif << 5), - rt->fl.fl4_tos); + unsigned hash = rt_hash(rt->fl.fl4_dst, rt->fl.fl4_src, + rt->fl.oif, rt->fl.fl4_tos); #if RT_CACHE_DEBUG >= 1 printk(KERN_DEBUG "ip_rt_advice: redirect to " "%u.%u.%u.%u/%02x dropped\n", @@ -1398,7 +1398,7 @@ unsigned short ip_rt_frag_needed(struct return 0; for (i = 0; i < 2; i++) { - unsigned hash = rt_hash_code(daddr, skeys[i], tos); + unsigned hash = rt_hash(daddr, skeys[i], 0, tos); rcu_read_lock(); for (rth = rcu_dereference(rt_hash_table[hash].chain); rth; @@ -1658,7 +1658,7 @@ static int ip_route_input_mc(struct sk_b RT_CACHE_STAT_INC(in_slow_mc); in_dev_put(in_dev); - hash = rt_hash_code(daddr, saddr ^ (dev->ifindex << 5), tos); + hash = rt_hash(daddr, saddr, dev->ifindex, tos); return rt_intern_hash(hash, rth, (struct rtable**) &skb->dst); e_nobufs: @@ -1823,7 +1823,7 @@ static inline int ip_mkroute_input_def(s return err; /* put it into the cache */ - hash = rt_hash_code(daddr, saddr ^ (fl->iif << 5), tos); + hash = rt_hash(daddr, saddr, fl->iif, tos); return rt_intern_hash(hash, rth, (struct rtable**)&skb->dst); } @@ -1864,7 +1864,7 @@ static inline int ip_mkroute_input(struc return err; /* put it into the cache */ - hash = rt_hash_code(daddr, saddr ^ (fl->iif << 5), tos); + hash = rt_hash(daddr, saddr, fl->iif, tos); err = rt_intern_hash(hash, rth, &rtres); if (err) return err; @@ -2041,7 +2041,7 @@ local_input: rth->rt_flags &= ~RTCF_LOCAL; } rth->rt_type = res.type; - hash = rt_hash_code(daddr, saddr ^ (fl.iif << 5), tos); + hash = rt_hash(daddr, saddr, fl.iif, tos); err = rt_intern_hash(hash, rth, (struct rtable**)&skb->dst); goto done; @@ -2088,7 +2088,7 @@ int ip_route_input(struct sk_buff *skb, int iif = dev->ifindex; tos &= IPTOS_RT_MASK; - hash = rt_hash_code(daddr, saddr ^ (iif << 5), tos); + hash = rt_hash(daddr, saddr, iif, tos); rcu_read_lock(); for (rth = rcu_dereference(rt_hash_table[hash].chain); rth; @@ -2288,8 +2288,8 @@ static inline int ip_mkroute_output_def( if (err == 0) { u32 tos = RT_FL_TOS(oldflp); - hash = rt_hash_code(oldflp->fl4_dst, - oldflp->fl4_src ^ (oldflp->oif << 5), tos); + hash = rt_hash(oldflp->fl4_dst, oldflp->fl4_src, + oldflp->oif, tos); err = rt_intern_hash(hash, rth, rp); } @@ -2332,9 +2332,8 @@ static inline int ip_mkroute_output(stru if (err != 0) goto cleanup; - hash = rt_hash_code(oldflp->fl4_dst, - oldflp->fl4_src ^ - (oldflp->oif << 5), tos); + hash = rt_hash(oldflp->fl4_dst, oldflp->fl4_src, + oldflp->oif, tos); err = rt_intern_hash(hash, rth, rp); /* forward hop information to multipath impl. */ @@ -2563,7 +2562,7 @@ int __ip_route_output_key(struct rtable unsigned hash; struct rtable *rth; - hash = rt_hash_code(flp->fl4_dst, flp->fl4_src ^ (flp->oif << 5), flp->fl4_tos); + hash = rt_hash(flp->fl4_dst, flp->fl4_src, flp->oif, flp->fl4_tos); rcu_read_lock_bh(); for (rth = rcu_dereference(rt_hash_table[hash].chain); rth; -- 0.99.9.GIT From nobody Mon Sep 17 00:00:00 2001 Subject: [PATCH] ip_route_connect() ipv4 address arguments annotated From: Al Viro Date: 1136469825 -0500 --- include/net/route.h | 4 ++-- net/dccp/ipv4.c | 2 +- net/ipv4/af_inet.c | 2 +- net/ipv4/datagram.c | 2 +- net/ipv4/tcp_ipv4.c | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) 80b3edb2415306e67b76ad596d2f8794b7384ee3 diff --git a/include/net/route.h b/include/net/route.h index 2e59e94..c78072e 100644 --- a/include/net/route.h +++ b/include/net/route.h @@ -144,8 +144,8 @@ static inline char rt_tos2priority(u8 to return ip_tos2prio[IPTOS_TOS(tos)>>1]; } -static inline int ip_route_connect(struct rtable **rp, u32 dst, - u32 src, u32 tos, int oif, u8 protocol, +static inline int ip_route_connect(struct rtable **rp, __be32 dst, + __be32 src, u32 tos, int oif, u8 protocol, u16 sport, u16 dport, struct sock *sk) { struct flowi fl = { .oif = oif, diff --git a/net/dccp/ipv4.c b/net/dccp/ipv4.c index 656e13e..af6ff3f 100644 --- a/net/dccp/ipv4.c +++ b/net/dccp/ipv4.c @@ -215,7 +215,7 @@ static int dccp_v4_connect(struct sock * struct dccp_sock *dp = dccp_sk(sk); const struct sockaddr_in *usin = (struct sockaddr_in *)uaddr; struct rtable *rt; - u32 daddr, nexthop; + __be32 daddr, nexthop; int tmp; int err; diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c index d368cf2..9fa9f9e 100644 --- a/net/ipv4/af_inet.c +++ b/net/ipv4/af_inet.c @@ -980,7 +980,7 @@ static int inet_sk_reselect_saddr(struct struct rtable *rt; __u32 old_saddr = inet->saddr; __u32 new_saddr; - __u32 daddr = inet->daddr; + __be32 daddr = inet->daddr; if (inet->opt && inet->opt->srr) daddr = inet->opt->faddr; diff --git a/net/ipv4/datagram.c b/net/ipv4/datagram.c index c1b42b5..644d687 100644 --- a/net/ipv4/datagram.c +++ b/net/ipv4/datagram.c @@ -26,7 +26,7 @@ int ip4_datagram_connect(struct sock *sk struct inet_sock *inet = inet_sk(sk); struct sockaddr_in *usin = (struct sockaddr_in *) uaddr; struct rtable *rt; - u32 saddr; + __be32 saddr; int oif; int err; diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index 4d5021e..1b67b38 100644 --- a/net/ipv4/tcp_ipv4.c +++ b/net/ipv4/tcp_ipv4.c @@ -322,7 +322,7 @@ int tcp_v4_connect(struct sock *sk, stru struct tcp_sock *tp = tcp_sk(sk); struct sockaddr_in *usin = (struct sockaddr_in *)uaddr; struct rtable *rt; - u32 daddr, nexthop; + __be32 daddr, nexthop; int tmp; int err; -- 0.99.9.GIT From nobody Mon Sep 17 00:00:00 2001 Subject: [PATCH] annotated ipv4 addresses in struct inet_sock From: Al Viro Date: 1136470549 -0500 --- include/linux/ip.h | 10 +++++----- 1 files changed, 5 insertions(+), 5 deletions(-) 70fb58f2e35b60c1789a17fa1e7c13a23f4de9fe diff --git a/include/linux/ip.h b/include/linux/ip.h index 68c22c3..c53161a 100644 --- a/include/linux/ip.h +++ b/include/linux/ip.h @@ -137,11 +137,11 @@ struct inet_sock { struct ipv6_pinfo *pinet6; #endif /* Socket demultiplex comparisons on incoming packets. */ - __u32 daddr; /* Foreign IPv4 addr */ - __u32 rcv_saddr; /* Bound local IPv4 addr */ + __be32 daddr; /* Foreign IPv4 addr */ + __be32 rcv_saddr; /* Bound local IPv4 addr */ __u16 dport; /* Destination port */ __u16 num; /* Local port */ - __u32 saddr; /* Sending source */ + __be32 saddr; /* Sending source */ __s16 uc_ttl; /* Unicast TTL */ __u16 cmsg_flags; struct ip_options *opt; @@ -155,7 +155,7 @@ struct inet_sock { hdrincl : 1, mc_loop : 1; int mc_index; /* Multicast device index */ - __u32 mc_addr; + __be32 mc_addr; struct ip_mc_socklist *mc_list; /* Group array */ /* * Following members are used to retain the infomation to build @@ -167,7 +167,7 @@ struct inet_sock { struct ip_options *opt; struct rtable *rt; int length; /* Total length of all frames */ - u32 addr; + __be32 addr; struct flowi fl; } cork; }; -- 0.99.9.GIT From nobody Mon Sep 17 00:00:00 2001 Subject: [PATCH] more ipv4/route.c endianness annotations From: Al Viro Date: 1136471049 -0500 --- net/ipv4/route.c | 9 +++++---- 1 files changed, 5 insertions(+), 4 deletions(-) a2ed8b4e75b389d6200bf7fc711c494f9c90ff8c diff --git a/net/ipv4/route.c b/net/ipv4/route.c index 494a95b..0c6025e 100644 --- a/net/ipv4/route.c +++ b/net/ipv4/route.c @@ -1070,7 +1070,7 @@ static void ip_select_fb_ident(struct ip u32 salt; spin_lock_bh(&ip_fb_id_lock); - salt = secure_ip_id(ip_fallback_id ^ iph->daddr); + salt = secure_ip_id(ip_fallback_id ^ (__force u32)iph->daddr); iph->id = htons(salt & 0xFFFF); ip_fallback_id = salt; spin_unlock_bh(&ip_fb_id_lock); @@ -1523,7 +1523,7 @@ static int ip_rt_bug(struct sk_buff *skb void ip_rt_get_source(u8 *addr, struct rtable *rt) { - u32 src; + __be32 src; struct fib_result res; if (rt->fl.iif == 0) @@ -1713,7 +1713,8 @@ static inline int __mkroute_input(struct int err; struct in_device *out_dev; unsigned flags = 0; - u32 spec_dst, itag; + __be32 spec_dst; + u32 itag; /* get a working reference to the output device */ out_dev = in_dev_get(FIB_RES_DEV(*res)); @@ -1913,7 +1914,7 @@ static int ip_route_input_slow(struct sk u32 itag = 0; struct rtable * rth; unsigned hash; - u32 spec_dst; + __be32 spec_dst; int err = -EINVAL; int free_res = 0; -- 0.99.9.GIT From nobody Mon Sep 17 00:00:00 2001 Subject: [PATCH] annotate inet_select_addr() callers From: Al Viro Date: 1136472137 -0500 --- include/linux/inetdevice.h | 2 +- net/ipv4/arp.c | 4 ++-- net/ipv4/devinet.c | 4 ++-- net/ipv4/icmp.c | 2 +- net/ipv4/ipvs/ip_vs_sync.c | 2 +- net/ipv4/netfilter/ipt_MASQUERADE.c | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) f4601088c7d3dcfdda73541d05d185fd1f0d8b9b diff --git a/include/linux/inetdevice.h b/include/linux/inetdevice.h index fd7af86..e62e648 100644 --- a/include/linux/inetdevice.h +++ b/include/linux/inetdevice.h @@ -109,7 +109,7 @@ extern int devinet_ioctl(unsigned int c extern void devinet_init(void); extern struct in_device *inetdev_init(struct net_device *dev); extern struct in_device *inetdev_by_index(int); -extern u32 inet_select_addr(const struct net_device *dev, u32 dst, int scope); +extern __be32 inet_select_addr(const struct net_device *dev, __be32 dst, int scope); extern u32 inet_confirm_addr(const struct net_device *dev, u32 dst, u32 local, int scope); extern struct in_ifaddr *inet_ifa_byprefix(struct in_device *in_dev, u32 prefix, u32 mask); extern void inet_forward_change(void); diff --git a/net/ipv4/arp.c b/net/ipv4/arp.c index ae27a70..d15f8fb 100644 --- a/net/ipv4/arp.c +++ b/net/ipv4/arp.c @@ -329,10 +329,10 @@ static void arp_error_report(struct neig static void arp_solicit(struct neighbour *neigh, struct sk_buff *skb) { - u32 saddr = 0; + __be32 saddr = 0; u8 *dst_ha = NULL; struct net_device *dev = neigh->dev; - u32 target = *(u32*)neigh->primary_key; + __be32 target = *(u32*)neigh->primary_key; int probes = atomic_read(&neigh->probes); struct in_device *in_dev = in_dev_get(dev); diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c index 04a6fe3..5fa4ac1 100644 --- a/net/ipv4/devinet.c +++ b/net/ipv4/devinet.c @@ -806,9 +806,9 @@ out: return done; } -u32 inet_select_addr(const struct net_device *dev, u32 dst, int scope) +__be32 inet_select_addr(const struct net_device *dev, __be32 dst, int scope) { - u32 addr = 0; + __be32 addr = 0; struct in_device *in_dev; rcu_read_lock(); diff --git a/net/ipv4/icmp.c b/net/ipv4/icmp.c index 92e23b2..986a9fc 100644 --- a/net/ipv4/icmp.c +++ b/net/ipv4/icmp.c @@ -437,7 +437,7 @@ void icmp_send(struct sk_buff *skb_in, i struct icmp_bxm icmp_param; struct rtable *rt = (struct rtable *)skb_in->dst; struct ipcm_cookie ipc; - u32 saddr; + __be32 saddr; u8 tos; if (!rt) diff --git a/net/ipv4/ipvs/ip_vs_sync.c b/net/ipv4/ipvs/ip_vs_sync.c index 2e5ced3..fb96c9b 100644 --- a/net/ipv4/ipvs/ip_vs_sync.c +++ b/net/ipv4/ipvs/ip_vs_sync.c @@ -462,7 +462,7 @@ join_mcast_group(struct sock *sk, struct static int bind_mcastif_addr(struct socket *sock, char *ifname) { struct net_device *dev; - u32 addr; + __be32 addr; struct sockaddr_in sin; if ((dev = __dev_get_by_name(ifname)) == NULL) diff --git a/net/ipv4/netfilter/ipt_MASQUERADE.c b/net/ipv4/netfilter/ipt_MASQUERADE.c index 275a174..924f7cd 100644 --- a/net/ipv4/netfilter/ipt_MASQUERADE.c +++ b/net/ipv4/netfilter/ipt_MASQUERADE.c @@ -82,7 +82,7 @@ masquerade_target(struct sk_buff **pskb, const struct ip_nat_multi_range_compat *mr; struct ip_nat_range newrange; struct rtable *rt; - u_int32_t newsrc; + __be32 newsrc; IP_NF_ASSERT(hooknum == NF_IP_POST_ROUTING); -- 0.99.9.GIT From nobody Mon Sep 17 00:00:00 2001 Subject: [PATCH] fib_validate_source() callers annotated From: Al Viro Date: 1136473500 -0500 --- include/net/ip_fib.h | 4 ++-- net/ipv4/fib_frontend.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) 701f3ec7b8d0a6b82b2af4f6e53e481ab709e4ac diff --git a/include/net/ip_fib.h b/include/net/ip_fib.h index 14de4eb..c0c47c1 100644 --- a/include/net/ip_fib.h +++ b/include/net/ip_fib.h @@ -234,8 +234,8 @@ extern int inet_rtm_delroute(struct sk_b extern int inet_rtm_newroute(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg); extern int inet_rtm_getroute(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg); extern int inet_dump_fib(struct sk_buff *skb, struct netlink_callback *cb); -extern int fib_validate_source(u32 src, u32 dst, u8 tos, int oif, - struct net_device *dev, u32 *spec_dst, u32 *itag); +extern int fib_validate_source(__be32 src, __be32 dst, u8 tos, int oif, + struct net_device *dev, __be32 *spec_dst, u32 *itag); extern void fib_select_multipath(const struct flowi *flp, struct fib_result *res); /* Exported by fib_semantics.c */ diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c index 19b1b98..7925f55 100644 --- a/net/ipv4/fib_frontend.c +++ b/net/ipv4/fib_frontend.c @@ -158,8 +158,8 @@ unsigned inet_addr_type(u32 addr) - check, that packet arrived from expected physical interface. */ -int fib_validate_source(u32 src, u32 dst, u8 tos, int oif, - struct net_device *dev, u32 *spec_dst, u32 *itag) +int fib_validate_source(__be32 src, __be32 dst, u8 tos, int oif, + struct net_device *dev, __be32 *spec_dst, u32 *itag) { struct in_device *in_dev; struct flowi fl = { .nl_u = { .ip4_u = -- 0.99.9.GIT From nobody Mon Sep 17 00:00:00 2001 Subject: [PATCH] ip_check_mc() callers annotated From: Al Viro Date: 1136474371 -0500 --- include/linux/igmp.h | 2 +- net/ipv4/igmp.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 7abca704983655f18e3abb6f9c1d0ba410b3c09e diff --git a/include/linux/igmp.h b/include/linux/igmp.h index 28f4f3b..5cd3ebb 100644 --- a/include/linux/igmp.h +++ b/include/linux/igmp.h @@ -197,7 +197,7 @@ struct ip_mc_list #define IGMPV3_QQIC(value) IGMPV3_EXP(0x80, 4, 3, value) #define IGMPV3_MRC(value) IGMPV3_EXP(0x80, 4, 3, value) -extern int ip_check_mc(struct in_device *dev, u32 mc_addr, u32 src_addr, u16 proto); +extern int ip_check_mc(struct in_device *dev, __be32 mc_addr, __be32 src_addr, u16 proto); extern int igmp_rcv(struct sk_buff *); extern int ip_mc_join_group(struct sock *sk, struct ip_mreqn *imr); extern int ip_mc_leave_group(struct sock *sk, struct ip_mreqn *imr); diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c index 4a195c7..7e46d6d 100644 --- a/net/ipv4/igmp.c +++ b/net/ipv4/igmp.c @@ -2120,7 +2120,7 @@ void ip_mc_drop_socket(struct sock *sk) rtnl_unlock(); } -int ip_check_mc(struct in_device *in_dev, u32 mc_addr, u32 src_addr, u16 proto) +int ip_check_mc(struct in_device *in_dev, __be32 mc_addr, __be32 src_addr, u16 proto) { struct ip_mc_list *im; struct ip_sf_list *psf; -- 0.99.9.GIT From nobody Mon Sep 17 00:00:00 2001 Subject: [PATCH] inet_addr_onlink() annotated From: Al Viro Date: 1136475059 -0500 --- include/linux/inetdevice.h | 2 +- net/ipv4/devinet.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 95234cdb8b72712eaae76d99941384b1fa0df5e5 diff --git a/include/linux/inetdevice.h b/include/linux/inetdevice.h index e62e648..4bb0963 100644 --- a/include/linux/inetdevice.h +++ b/include/linux/inetdevice.h @@ -104,7 +104,7 @@ extern int register_inetaddr_notifier(st extern int unregister_inetaddr_notifier(struct notifier_block *nb); extern struct net_device *ip_dev_find(u32 addr); -extern int inet_addr_onlink(struct in_device *in_dev, u32 a, u32 b); +extern int inet_addr_onlink(struct in_device *in_dev, __be32 a, __be32 b); extern int devinet_ioctl(unsigned int cmd, void __user *); extern void devinet_init(void); extern struct in_device *inetdev_init(struct net_device *dev); diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c index 5fa4ac1..d7fae28 100644 --- a/net/ipv4/devinet.c +++ b/net/ipv4/devinet.c @@ -215,7 +215,7 @@ static void inetdev_destroy(struct in_de call_rcu(&in_dev->rcu_head, in_dev_rcu_put); } -int inet_addr_onlink(struct in_device *in_dev, u32 a, u32 b) +int inet_addr_onlink(struct in_device *in_dev, __be32 a, __be32 b) { rcu_read_lock(); for_primary_ifa(in_dev) { -- 0.99.9.GIT From nobody Mon Sep 17 00:00:00 2001 Subject: [PATCH] fib_hn ->nh_gw is big-endian From: Al Viro Date: 1136515040 -0500 --- include/net/ip_fib.h | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) 411260c842711b3f41436428604ae0cdedb33f0d diff --git a/include/net/ip_fib.h b/include/net/ip_fib.h index c0c47c1..215871d 100644 --- a/include/net/ip_fib.h +++ b/include/net/ip_fib.h @@ -56,7 +56,7 @@ struct fib_nh { __u32 nh_tclassid; #endif int nh_oif; - u32 nh_gw; + __be32 nh_gw; }; /* -- 0.99.9.GIT From nobody Mon Sep 17 00:00:00 2001 Subject: [PATCH] FIB_RES_PREFSRC() annotated From: Al Viro Date: 1136515504 -0500 --- include/net/ip_fib.h | 4 ++-- net/ipv4/fib_semantics.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) 27d5de01a7469db000dc10434ff597a31b27e132 diff --git a/include/net/ip_fib.h b/include/net/ip_fib.h index 215871d..de96449 100644 --- a/include/net/ip_fib.h +++ b/include/net/ip_fib.h @@ -71,7 +71,7 @@ struct fib_info { int fib_dead; unsigned fib_flags; int fib_protocol; - u32 fib_prefsrc; + __be32 fib_prefsrc; u32 fib_priority; u32 fib_metrics[RTAX_MAX]; #define fib_mtu fib_metrics[RTAX_MTU-1] @@ -244,7 +244,7 @@ extern int fib_sync_down(u32 local, stru extern int fib_sync_up(struct net_device *dev); extern int fib_convert_rtentry(int cmd, struct nlmsghdr *nl, struct rtmsg *rtm, struct kern_rta *rta, struct rtentry *r); -extern u32 __fib_res_prefsrc(struct fib_result *res); +extern __be32 __fib_res_prefsrc(struct fib_result *res); /* Exported by fib_hash.c */ extern struct fib_table *fib_hash_init(int id); diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c index 6d2a6ac..b8bc84c 100644 --- a/net/ipv4/fib_semantics.c +++ b/net/ipv4/fib_semantics.c @@ -932,7 +932,7 @@ out_fill_res: /* Find appropriate source address to this destination */ -u32 __fib_res_prefsrc(struct fib_result *res) +__be32 __fib_res_prefsrc(struct fib_result *res) { return inet_select_addr(FIB_RES_DEV(*res), FIB_RES_GW(*res), res->scope); } -- 0.99.9.GIT From nobody Mon Sep 17 00:00:00 2001 Subject: [PATCH] inetdev.h annotations From: Al Viro Date: 1136517388 -0500 struct in_ifaddr, inet_confirm_addr(), inet_ifa_byprefix(), ip_dev_find(), inet_make_mask(), inet_ifa_match() --- include/linux/inetdevice.h | 20 ++++++++++---------- net/ipv4/devinet.c | 14 +++++++------- net/ipv4/fib_frontend.c | 12 ++++++------ 3 files changed, 23 insertions(+), 23 deletions(-) 4d1fdfa25d15fe8a540d3bb3354d5702c7be8087 diff --git a/include/linux/inetdevice.h b/include/linux/inetdevice.h index 4bb0963..f796a75 100644 --- a/include/linux/inetdevice.h +++ b/include/linux/inetdevice.h @@ -89,11 +89,11 @@ struct in_ifaddr struct in_ifaddr *ifa_next; struct in_device *ifa_dev; struct rcu_head rcu_head; - u32 ifa_local; - u32 ifa_address; - u32 ifa_mask; - u32 ifa_broadcast; - u32 ifa_anycast; + __be32 ifa_local; + __be32 ifa_address; + __be32 ifa_mask; + __be32 ifa_broadcast; + __be32 ifa_anycast; unsigned char ifa_scope; unsigned char ifa_flags; unsigned char ifa_prefixlen; @@ -103,18 +103,18 @@ struct in_ifaddr extern int register_inetaddr_notifier(struct notifier_block *nb); extern int unregister_inetaddr_notifier(struct notifier_block *nb); -extern struct net_device *ip_dev_find(u32 addr); +extern struct net_device *ip_dev_find(__be32 addr); extern int inet_addr_onlink(struct in_device *in_dev, __be32 a, __be32 b); extern int devinet_ioctl(unsigned int cmd, void __user *); extern void devinet_init(void); extern struct in_device *inetdev_init(struct net_device *dev); extern struct in_device *inetdev_by_index(int); extern __be32 inet_select_addr(const struct net_device *dev, __be32 dst, int scope); -extern u32 inet_confirm_addr(const struct net_device *dev, u32 dst, u32 local, int scope); -extern struct in_ifaddr *inet_ifa_byprefix(struct in_device *in_dev, u32 prefix, u32 mask); +extern __be32 inet_confirm_addr(const struct net_device *dev, __be32 dst, __be32 local, int scope); +extern struct in_ifaddr *inet_ifa_byprefix(struct in_device *in_dev, __be32 prefix, __be32 mask); extern void inet_forward_change(void); -static __inline__ int inet_ifa_match(u32 addr, struct in_ifaddr *ifa) +static __inline__ int inet_ifa_match(__be32 addr, struct in_ifaddr *ifa) { return !((addr^ifa->ifa_address)&ifa->ifa_mask); } @@ -182,7 +182,7 @@ static inline void in_dev_put(struct in_ #endif /* __KERNEL__ */ -static __inline__ __u32 inet_make_mask(int logmask) +static __inline__ __be32 inet_make_mask(int logmask) { if (logmask) return htonl(~((1<<(32-logmask))-1)); diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c index d7fae28..d1168b3 100644 --- a/net/ipv4/devinet.c +++ b/net/ipv4/devinet.c @@ -406,8 +406,8 @@ struct in_device *inetdev_by_index(int i /* Called only from RTNL semaphored context. No locks. */ -struct in_ifaddr *inet_ifa_byprefix(struct in_device *in_dev, u32 prefix, - u32 mask) +struct in_ifaddr *inet_ifa_byprefix(struct in_device *in_dev, __be32 prefix, + __be32 mask) { ASSERT_RTNL(); @@ -857,11 +857,11 @@ out: return addr; } -static u32 confirm_addr_indev(struct in_device *in_dev, u32 dst, - u32 local, int scope) +static __be32 confirm_addr_indev(struct in_device *in_dev, __be32 dst, + __be32 local, int scope) { int same = 0; - u32 addr = 0; + __be32 addr = 0; for_ifa(in_dev) { if (!addr && @@ -901,9 +901,9 @@ static u32 confirm_addr_indev(struct in_ * - local: address, 0=autoselect the local address * - scope: maximum allowed scope value for the local address */ -u32 inet_confirm_addr(const struct net_device *dev, u32 dst, u32 local, int scope) +__be32 inet_confirm_addr(const struct net_device *dev, __be32 dst, __be32 local, int scope) { - u32 addr = 0; + __be32 addr = 0; struct in_device *in_dev; if (dev) { diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c index 7925f55..da3fba5 100644 --- a/net/ipv4/fib_frontend.c +++ b/net/ipv4/fib_frontend.c @@ -100,7 +100,7 @@ static void fib_flush(void) * Find the first device with a given source address. */ -struct net_device * ip_dev_find(u32 addr) +struct net_device * ip_dev_find(__be32 addr) { struct flowi fl = { .nl_u = { .ip4_u = { .daddr = addr } } }; struct fib_result res; @@ -412,9 +412,9 @@ void fib_add_ifaddr(struct in_ifaddr *if struct in_device *in_dev = ifa->ifa_dev; struct net_device *dev = in_dev->dev; struct in_ifaddr *prim = ifa; - u32 mask = ifa->ifa_mask; - u32 addr = ifa->ifa_local; - u32 prefix = ifa->ifa_address&mask; + __be32 mask = ifa->ifa_mask; + __be32 addr = ifa->ifa_local; + __be32 prefix = ifa->ifa_address&mask; if (ifa->ifa_flags&IFA_F_SECONDARY) { prim = inet_ifa_byprefix(in_dev, prefix, mask); @@ -452,8 +452,8 @@ static void fib_del_ifaddr(struct in_ifa struct net_device *dev = in_dev->dev; struct in_ifaddr *ifa1; struct in_ifaddr *prim = ifa; - u32 brd = ifa->ifa_address|~ifa->ifa_mask; - u32 any = ifa->ifa_address&ifa->ifa_mask; + __be32 brd = ifa->ifa_address|~ifa->ifa_mask; + __be32 any = ifa->ifa_address&ifa->ifa_mask; #define LOCAL_OK 1 #define BRD_OK 2 #define BRD0_OK 4 -- 0.99.9.GIT From nobody Mon Sep 17 00:00:00 2001 Subject: [PATCH] icmp_send() annotated From: Al Viro Date: 1136518451 -0500 --- include/net/icmp.h | 2 +- net/ipv4/icmp.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) d4205b933e0e5706e2c22b29dc17fd9d2f2d4336 diff --git a/include/net/icmp.h b/include/net/icmp.h index 6cdebee..be6eefe 100644 --- a/include/net/icmp.h +++ b/include/net/icmp.h @@ -38,7 +38,7 @@ DECLARE_SNMP_STAT(struct icmp_mib, icmp_ #define ICMP_INC_STATS_BH(field) SNMP_INC_STATS_BH(icmp_statistics, field) #define ICMP_INC_STATS_USER(field) SNMP_INC_STATS_USER(icmp_statistics, field) -extern void icmp_send(struct sk_buff *skb_in, int type, int code, u32 info); +extern void icmp_send(struct sk_buff *skb_in, int type, int code, __be32 info); extern int icmp_rcv(struct sk_buff *skb); extern int icmp_ioctl(struct sock *sk, int cmd, unsigned long arg); extern void icmp_init(struct net_proto_family *ops); diff --git a/net/ipv4/icmp.c b/net/ipv4/icmp.c index 986a9fc..3211a36 100644 --- a/net/ipv4/icmp.c +++ b/net/ipv4/icmp.c @@ -430,7 +430,7 @@ out:; * MUST reply to only the first fragment. */ -void icmp_send(struct sk_buff *skb_in, int type, int code, u32 info) +void icmp_send(struct sk_buff *skb_in, int type, int code, __be32 info) { struct iphdr *iph; int room; -- 0.99.9.GIT From nobody Mon Sep 17 00:00:00 2001 Subject: [PATCH] inet_addr_type() callers annotated From: Al Viro Date: 1136519156 -0500 --- include/net/route.h | 2 +- net/ipv4/arp.c | 4 ++-- net/ipv4/fib_frontend.c | 2 +- net/ipv4/fib_semantics.c | 2 +- net/ipv4/ip_options.c | 4 ++-- net/ipv4/netfilter/ipt_addrtype.c | 2 +- net/ipv6/af_inet6.c | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) d5bde647acbb5137781a3cbf9dbd8f2d00577da1 diff --git a/include/net/route.h b/include/net/route.h index c78072e..3df36a0 100644 --- a/include/net/route.h +++ b/include/net/route.h @@ -120,7 +120,7 @@ extern int ip_route_input(struct sk_buf extern unsigned short ip_rt_frag_needed(struct iphdr *iph, unsigned short new_mtu); extern void ip_rt_send_redirect(struct sk_buff *skb); -extern unsigned inet_addr_type(u32 addr); +extern unsigned inet_addr_type(__be32 addr); extern void ip_rt_multicast_event(struct in_device *); extern int ip_rt_ioctl(unsigned int cmd, void __user *arg); extern void ip_rt_get_source(u8 *src, struct rtable *rt); diff --git a/net/ipv4/arp.c b/net/ipv4/arp.c index d15f8fb..27b5a45 100644 --- a/net/ipv4/arp.c +++ b/net/ipv4/arp.c @@ -233,7 +233,7 @@ static u32 arp_hash(const void *pkey, co static int arp_constructor(struct neighbour *neigh) { - u32 addr = *(u32*)neigh->primary_key; + __be32 addr = *(u32*)neigh->primary_key; struct net_device *dev = neigh->dev; struct in_device *in_dev; struct neigh_parms *parms; @@ -469,7 +469,7 @@ static int arp_set_predefined(int addr_h int arp_find(unsigned char *haddr, struct sk_buff *skb) { struct net_device *dev = skb->dev; - u32 paddr; + __be32 paddr; struct neighbour *n; if (!skb->dst) { diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c index da3fba5..010e0fc 100644 --- a/net/ipv4/fib_frontend.c +++ b/net/ipv4/fib_frontend.c @@ -124,7 +124,7 @@ out: return dev; } -unsigned inet_addr_type(u32 addr) +unsigned inet_addr_type(__be32 addr) { struct flowi fl = { .nl_u = { .ip4_u = { .daddr = addr } } }; struct fib_result res; diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c index b8bc84c..b2b3580 100644 --- a/net/ipv4/fib_semantics.c +++ b/net/ipv4/fib_semantics.c @@ -1014,7 +1014,7 @@ fib_convert_rtentry(int cmd, struct nlms struct kern_rta *rta, struct rtentry *r) { int plen; - u32 *ptr; + __be32 *ptr; memset(rtm, 0, sizeof(*rtm)); memset(rta, 0, sizeof(*rta)); diff --git a/net/ipv4/ip_options.c b/net/ipv4/ip_options.c index cd894ec..300d200 100644 --- a/net/ipv4/ip_options.c +++ b/net/ipv4/ip_options.c @@ -145,7 +145,7 @@ int ip_options_echo(struct ip_options * dopt->ts_needtime = 0; if (soffset + 8 <= optlen) { - __u32 addr; + __be32 addr; memcpy(&addr, sptr+soffset-1, 4); if (inet_addr_type(addr) != RTN_LOCAL) { @@ -387,7 +387,7 @@ int ip_options_compile(struct ip_options } opt->ts = optptr - iph; { - u32 addr; + __be32 addr; memcpy(&addr, &optptr[optptr[2]-1], 4); if (inet_addr_type(addr) == RTN_UNICAST) break; diff --git a/net/ipv4/netfilter/ipt_addrtype.c b/net/ipv4/netfilter/ipt_addrtype.c index e19c2a5..7d347e4 100644 --- a/net/ipv4/netfilter/ipt_addrtype.c +++ b/net/ipv4/netfilter/ipt_addrtype.c @@ -22,7 +22,7 @@ MODULE_LICENSE("GPL"); MODULE_AUTHOR("Patrick McHardy "); MODULE_DESCRIPTION("iptables addrtype match"); -static inline int match_type(u_int32_t addr, u_int16_t mask) +static inline int match_type(__be32 addr, u_int16_t mask) { return !!(mask & (1 << inet_addr_type(addr))); } diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c index d954638..01527ee 100644 --- a/net/ipv6/af_inet6.c +++ b/net/ipv6/af_inet6.c @@ -242,7 +242,7 @@ int inet6_bind(struct socket *sock, stru struct sock *sk = sock->sk; struct inet_sock *inet = inet_sk(sk); struct ipv6_pinfo *np = inet6_sk(sk); - __u32 v4addr = 0; + __be32 v4addr = 0; unsigned short snum; int addr_type = 0; int err = 0; -- 0.99.9.GIT From nobody Mon Sep 17 00:00:00 2001 Subject: [PATCH] ip_fib_check_default() annotated From: Al Viro Date: 1136519433 -0500 --- include/net/ip_fib.h | 2 +- net/ipv4/fib_semantics.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) a802d643b4d70bdead99ad25a4106734d510cb7b diff --git a/include/net/ip_fib.h b/include/net/ip_fib.h index de96449..12f7f52 100644 --- a/include/net/ip_fib.h +++ b/include/net/ip_fib.h @@ -239,7 +239,7 @@ extern int fib_validate_source(__be32 sr extern void fib_select_multipath(const struct flowi *flp, struct fib_result *res); /* Exported by fib_semantics.c */ -extern int ip_fib_check_default(u32 gw, struct net_device *dev); +extern int ip_fib_check_default(__be32 gw, struct net_device *dev); extern int fib_sync_down(u32 local, struct net_device *dev, int force); extern int fib_sync_up(struct net_device *dev); extern int fib_convert_rtentry(int cmd, struct nlmsghdr *nl, struct rtmsg *rtm, diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c index b2b3580..970f950 100644 --- a/net/ipv4/fib_semantics.c +++ b/net/ipv4/fib_semantics.c @@ -246,7 +246,7 @@ static inline unsigned int fib_devindex_ Used only by redirect accept routine. */ -int ip_fib_check_default(u32 gw, struct net_device *dev) +int ip_fib_check_default(__be32 gw, struct net_device *dev) { struct hlist_head *head; struct hlist_node *node; -- 0.99.9.GIT From nobody Mon Sep 17 00:00:00 2001 Subject: [PATCH] ip_fragment.c endianness annotations From: Al Viro Date: 1136520021 -0500 --- net/ipv4/ip_fragment.c | 17 +++++++++-------- 1 files changed, 9 insertions(+), 8 deletions(-) 06db9f2f2f0854cda180c5c1cb226f5017caa3a4 diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c index 8ce0ce2..cddd712 100644 --- a/net/ipv4/ip_fragment.c +++ b/net/ipv4/ip_fragment.c @@ -74,9 +74,9 @@ struct ipq { struct hlist_node list; struct list_head lru_list; /* lru list member */ u32 user; - u32 saddr; - u32 daddr; - u16 id; + __be32 saddr; + __be32 daddr; + __be16 id; u8 protocol; u8 last_in; #define COMPLETE 4 @@ -118,9 +118,10 @@ static __inline__ void ipq_unlink(struct write_unlock(&ipfrag_lock); } -static unsigned int ipqhashfn(u16 id, u32 saddr, u32 daddr, u8 prot) +static unsigned int ipqhashfn(__be16 id, __be32 saddr, __be32 daddr, u8 prot) { - return jhash_3words((u32)id << 16 | prot, saddr, daddr, + return jhash_3words((__force u32)id << 16 | prot, + (__force u32)saddr, (__force u32)daddr, ipfrag_hash_rnd) & (IPQ_HASHSZ - 1); } @@ -373,9 +374,9 @@ out_nomem: */ static inline struct ipq *ip_find(struct iphdr *iph, u32 user) { - __u16 id = iph->id; - __u32 saddr = iph->saddr; - __u32 daddr = iph->daddr; + __be16 id = iph->id; + __be32 saddr = iph->saddr; + __be32 daddr = iph->daddr; __u8 protocol = iph->protocol; unsigned int hash = ipqhashfn(id, saddr, daddr, protocol); struct ipq *qp; -- 0.99.9.GIT From nobody Mon Sep 17 00:00:00 2001 Subject: [PATCH] ip_options.c annotated From: Al Viro Date: 1136532081 -0500 --- net/ipv4/ip_options.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) 3fc8142f5af2dbbf7bbd2e1665104a63c111655b diff --git a/net/ipv4/ip_options.c b/net/ipv4/ip_options.c index 300d200..dd1c2f9 100644 --- a/net/ipv4/ip_options.c +++ b/net/ipv4/ip_options.c @@ -54,7 +54,7 @@ void ip_options_build(struct sk_buff * s ip_rt_get_source(iph+opt->ts+iph[opt->ts+2]-9, rt); if (opt->ts_needtime) { struct timeval tv; - __u32 midtime; + __be32 midtime; do_gettimeofday(&tv); midtime = htonl((tv.tv_sec % 86400) * 1000 + tv.tv_usec / 1000); memcpy(iph+opt->ts+iph[opt->ts+2]-5, &midtime, 4); @@ -88,7 +88,7 @@ int ip_options_echo(struct ip_options * unsigned char *sptr, *dptr; int soffset, doffset; int optlen; - u32 daddr; + __be32 daddr; memset(dopt, 0, sizeof(struct ip_options)); @@ -406,7 +406,7 @@ int ip_options_compile(struct ip_options } if (timeptr) { struct timeval tv; - __u32 midtime; + __be32 midtime; do_gettimeofday(&tv); midtime = htonl((tv.tv_sec % 86400) * 1000 + tv.tv_usec / 1000); memcpy(timeptr, &midtime, sizeof(__u32)); -- 0.99.9.GIT From nobody Mon Sep 17 00:00:00 2001 Subject: [PATCH] more trivial annotations (ip_output.c) From: Al Viro Date: 1136532997 -0500 --- include/linux/ip.h | 2 +- include/net/ip.h | 2 +- net/ipv4/ip_options.c | 2 +- net/ipv4/ip_output.c | 6 +++--- 4 files changed, 6 insertions(+), 6 deletions(-) 9fc66bde39bd593df75d5d04ac4fb428aed8da55 diff --git a/include/linux/ip.h b/include/linux/ip.h index c53161a..a802fca 100644 --- a/include/linux/ip.h +++ b/include/linux/ip.h @@ -87,7 +87,7 @@ #include struct ip_options { - __u32 faddr; /* Saved first hop address */ + __be32 faddr; /* Saved first hop address */ unsigned char optlen; unsigned char srr; unsigned char rr; diff --git a/include/net/ip.h b/include/net/ip.h index e4563bb..a7c14f1 100644 --- a/include/net/ip.h +++ b/include/net/ip.h @@ -49,7 +49,7 @@ struct inet_skb_parm struct ipcm_cookie { - u32 addr; + __be32 addr; int oif; struct ip_options *opt; }; diff --git a/net/ipv4/ip_options.c b/net/ipv4/ip_options.c index dd1c2f9..470ee66 100644 --- a/net/ipv4/ip_options.c +++ b/net/ipv4/ip_options.c @@ -162,7 +162,7 @@ int ip_options_echo(struct ip_options * } if (sopt->srr) { unsigned char * start = sptr+sopt->srr; - u32 faddr; + __be32 faddr; optlen = start[1]; soffset = start[2]; diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c index eba64e2..c4bed5c 100644 --- a/net/ipv4/ip_output.c +++ b/net/ipv4/ip_output.c @@ -300,7 +300,7 @@ int ip_queue_xmit(struct sk_buff *skb, i /* Make sure we can route this packet. */ rt = (struct rtable *)__sk_dst_check(sk, 0); if (rt == NULL) { - u32 daddr; + __be32 daddr; /* Use correct destination address if we have options. */ daddr = inet->daddr; @@ -335,7 +335,7 @@ packet_routed: /* OK, we know where to send it, allocate and build IP header. */ iph = (struct iphdr *) skb_push(skb, sizeof(struct iphdr) + (opt ? opt->optlen : 0)); - *((__u16 *)iph) = htons((4 << 12) | (5 << 8) | (inet->tos & 0xff)); + *((__be16 *)iph) = htons((4 << 12) | (5 << 8) | (inet->tos & 0xff)); iph->tot_len = htons(skb->len); if (ip_dont_fragment(sk, &rt->u.dst) && !ipfragok) iph->frag_off = htons(IP_DF); @@ -1328,7 +1328,7 @@ void ip_send_reply(struct sock *sk, stru char data[40]; } replyopts; struct ipcm_cookie ipc; - u32 daddr; + __be32 daddr; struct rtable *rt = (struct rtable*)skb->dst; if (ip_options_echo(&replyopts.opt, skb)) -- 0.99.9.GIT From nobody Mon Sep 17 00:00:00 2001 Subject: [PATCH] ip_options_build() From: Al Viro Date: 1136533123 -0500 --- include/net/ip.h | 2 +- net/ipv4/ip_options.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 677431d234beb844408c76e0d7d7e5f2fe286c46 diff --git a/include/net/ip.h b/include/net/ip.h index a7c14f1..54a3549 100644 --- a/include/net/ip.h +++ b/include/net/ip.h @@ -331,7 +331,7 @@ extern int ip_net_unreachable(struct sk_ * Functions provided by ip_options.c */ -extern void ip_options_build(struct sk_buff *skb, struct ip_options *opt, u32 daddr, struct rtable *rt, int is_frag); +extern void ip_options_build(struct sk_buff *skb, struct ip_options *opt, __be32 daddr, struct rtable *rt, int is_frag); extern int ip_options_echo(struct ip_options *dopt, struct sk_buff *skb); extern void ip_options_fragment(struct sk_buff *skb); extern int ip_options_compile(struct ip_options *opt, struct sk_buff *skb); diff --git a/net/ipv4/ip_options.c b/net/ipv4/ip_options.c index 470ee66..cbd6484 100644 --- a/net/ipv4/ip_options.c +++ b/net/ipv4/ip_options.c @@ -35,7 +35,7 @@ */ void ip_options_build(struct sk_buff * skb, struct ip_options * opt, - u32 daddr, struct rtable *rt, int is_frag) + __be32 daddr, struct rtable *rt, int is_frag) { unsigned char * iph = skb->nh.raw; -- 0.99.9.GIT From nobody Mon Sep 17 00:00:00 2001 Subject: [PATCH] ip_local_error() ipv4 address argument annotated From: Al Viro Date: 1136533208 -0500 --- include/net/ip.h | 2 +- net/ipv4/ip_sockglue.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 9952d5485c66c84dbcec6dabba64c5308ebb57b3 diff --git a/include/net/ip.h b/include/net/ip.h index 54a3549..acb1249 100644 --- a/include/net/ip.h +++ b/include/net/ip.h @@ -356,7 +356,7 @@ extern int ip_ra_control(struct sock *sk extern int ip_recv_error(struct sock *sk, struct msghdr *msg, int len); extern void ip_icmp_error(struct sock *sk, struct sk_buff *skb, int err, u16 port, u32 info, u8 *payload); -extern void ip_local_error(struct sock *sk, int err, u32 daddr, u16 dport, +extern void ip_local_error(struct sock *sk, int err, __be32 daddr, u16 dport, u32 info); /* sysctl helpers - any sysctl which holds a value that ends up being diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c index 4f2d872..400337c 100644 --- a/net/ipv4/ip_sockglue.c +++ b/net/ipv4/ip_sockglue.c @@ -260,7 +260,7 @@ void ip_icmp_error(struct sock *sk, stru kfree_skb(skb); } -void ip_local_error(struct sock *sk, int err, u32 daddr, u16 port, u32 info) +void ip_local_error(struct sock *sk, int err, __be32 daddr, u16 port, u32 info) { struct inet_sock *inet = inet_sk(sk); struct sock_exterr_skb *serr; -- 0.99.9.GIT From nobody Mon Sep 17 00:00:00 2001 Subject: [PATCH] ip_buil_and_send_pkt() From: Al Viro Date: 1136533886 -0500 --- include/net/ip.h | 2 +- net/ipv4/ip_output.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) c8b8257883bc2af17171ee6b295068fcc2c93ed3 diff --git a/include/net/ip.h b/include/net/ip.h index acb1249..91e2d35 100644 --- a/include/net/ip.h +++ b/include/net/ip.h @@ -83,7 +83,7 @@ extern int igmp_mc_proc_init(void); */ extern int ip_build_and_send_pkt(struct sk_buff *skb, struct sock *sk, - u32 saddr, u32 daddr, + __be32 saddr, __be32 daddr, struct ip_options *opt); extern int ip_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt, struct net_device *orig_dev); diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c index c4bed5c..1190edf 100644 --- a/net/ipv4/ip_output.c +++ b/net/ipv4/ip_output.c @@ -118,7 +118,7 @@ static inline int ip_select_ttl(struct i * */ int ip_build_and_send_pkt(struct sk_buff *skb, struct sock *sk, - u32 saddr, u32 daddr, struct ip_options *opt) + __be32 saddr, __be32 daddr, struct ip_options *opt) { struct inet_sock *inet = inet_sk(sk); struct rtable *rt = (struct rtable *)skb->dst; -- 0.99.9.GIT From nobody Mon Sep 17 00:00:00 2001 Subject: [PATCH] inet_request_sock ipv4 address fields From: Al Viro Date: 1136534268 -0500 --- include/linux/ip.h | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) 49a05f2cb28cae53f77ac47e3fe2cb0b6c446f60 diff --git a/include/linux/ip.h b/include/linux/ip.h index a802fca..bc57f0e 100644 --- a/include/linux/ip.h +++ b/include/linux/ip.h @@ -110,8 +110,8 @@ struct ip_options { struct inet_request_sock { struct request_sock req; - u32 loc_addr; - u32 rmt_addr; + __be32 loc_addr; + __be32 rmt_addr; u16 rmt_port; u16 snd_wscale : 4, rcv_wscale : 4, -- 0.99.9.GIT From nobody Mon Sep 17 00:00:00 2001 Subject: [PATCH] ip_msfilter, ip_mreq_source ipv4 address fields From: Al Viro Date: 1136534885 -0500 --- include/linux/in.h | 12 ++++++------ 1 files changed, 6 insertions(+), 6 deletions(-) 3f1f47a2c95ec6b49b9e06af1d72e6e4192f504f diff --git a/include/linux/in.h b/include/linux/in.h index 2d22686..4e9b24d 100644 --- a/include/linux/in.h +++ b/include/linux/in.h @@ -122,17 +122,17 @@ struct ip_mreqn }; struct ip_mreq_source { - __u32 imr_multiaddr; - __u32 imr_interface; - __u32 imr_sourceaddr; + __be32 imr_multiaddr; + __be32 imr_interface; + __be32 imr_sourceaddr; }; struct ip_msfilter { - __u32 imsf_multiaddr; - __u32 imsf_interface; + __be32 imsf_multiaddr; + __be32 imsf_interface; __u32 imsf_fmode; __u32 imsf_numsrc; - __u32 imsf_slist[1]; + __be32 imsf_slist[1]; }; #define IP_MSFILTER_SIZE(numsrc) \ -- 0.99.9.GIT From nobody Mon Sep 17 00:00:00 2001 Subject: [PATCH] tcp header From: Al Viro Date: 1136535148 -0500 --- include/linux/tcp.h | 16 ++++++++-------- 1 files changed, 8 insertions(+), 8 deletions(-) ebd1fe9549da3818fd3cadd527593922fe6122b1 diff --git a/include/linux/tcp.h b/include/linux/tcp.h index 0e1da66..6a3129d 100644 --- a/include/linux/tcp.h +++ b/include/linux/tcp.h @@ -21,10 +21,10 @@ #include struct tcphdr { - __u16 source; - __u16 dest; - __u32 seq; - __u32 ack_seq; + __be16 source; + __be16 dest; + __be32 seq; + __be32 ack_seq; #if defined(__LITTLE_ENDIAN_BITFIELD) __u16 res1:4, doff:4, @@ -50,9 +50,9 @@ struct tcphdr { #else #error "Adjust your defines" #endif - __u16 window; - __u16 check; - __u16 urg_ptr; + __be16 window; + __be16 check; + __be16 urg_ptr; }; #define TCP_ACTION_FIN (1 << 7) @@ -78,7 +78,7 @@ enum { */ union tcp_word_hdr { struct tcphdr hdr; - __u32 words[5]; + __be32 words[5]; }; #define tcp_flag_word(tp) ( ((union tcp_word_hdr *)(tp))->words [3]) -- 0.99.9.GIT From nobody Mon Sep 17 00:00:00 2001 Subject: [PATCH] tcp_sack_block From: Al Viro Date: 1136537137 -0500 --- include/linux/tcp.h | 5 +++++ net/ipv4/netfilter/ip_nat_helper.c | 2 +- net/ipv4/tcp_input.c | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) d36e8bf98cd8c7289a77abd55d7cf3e9bfc20db2 diff --git a/include/linux/tcp.h b/include/linux/tcp.h index 6a3129d..c02ab3e 100644 --- a/include/linux/tcp.h +++ b/include/linux/tcp.h @@ -182,6 +182,11 @@ struct tcp_info #include /* This defines a selective acknowledgement block. */ +struct tcp_sack_block_wire { + __be32 start_seq; + __be32 end_seq; +}; + struct tcp_sack_block { __u32 start_seq; __u32 end_seq; diff --git a/net/ipv4/netfilter/ip_nat_helper.c b/net/ipv4/netfilter/ip_nat_helper.c index 5d506e0..2ba583c 100644 --- a/net/ipv4/netfilter/ip_nat_helper.c +++ b/net/ipv4/netfilter/ip_nat_helper.c @@ -268,7 +268,7 @@ sack_adjust(struct sk_buff *skb, struct ip_nat_seq *natseq) { while (sackoff < sackend) { - struct tcp_sack_block *sack; + struct tcp_sack_block_wire *sack; u_int32_t new_start_seq, new_end_seq; sack = (void *)skb->data + sackoff; diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index bf2e230..123534a 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -891,7 +891,7 @@ tcp_sacktag_write_queue(struct sock *sk, const struct inet_connection_sock *icsk = inet_csk(sk); struct tcp_sock *tp = tcp_sk(sk); unsigned char *ptr = ack_skb->h.raw + TCP_SKB_CB(ack_skb)->sacked; - struct tcp_sack_block *sp = (struct tcp_sack_block *)(ptr+2); + struct tcp_sack_block_wire *sp = (struct tcp_sack_block_wire *)(ptr+2); int num_sacks = (ptr[1] - TCPOLEN_SACK_BASE)>>3; int reord = tp->packets_out; int prior_fackets; -- 0.99.9.GIT From nobody Mon Sep 17 00:00:00 2001 Subject: [PATCH] tcp_input.c misc From: Al Viro Date: 1136537217 -0500 --- net/ipv4/tcp_input.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) 26b109ea9a694500c8b00cce2a921170da8a558a diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index 123534a..8a0d2bc 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -2525,7 +2525,7 @@ void tcp_parse_options(struct sk_buff *s switch(opcode) { case TCPOPT_MSS: if(opsize==TCPOLEN_MSS && th->syn && !estab) { - u16 in_mss = ntohs(get_unaligned((__u16 *)ptr)); + u16 in_mss = ntohs(get_unaligned((__be16 *)ptr)); if (in_mss) { if (opt_rx->user_mss && opt_rx->user_mss < in_mss) in_mss = opt_rx->user_mss; @@ -2553,8 +2553,8 @@ void tcp_parse_options(struct sk_buff *s if ((estab && opt_rx->tstamp_ok) || (!estab && sysctl_tcp_timestamps)) { opt_rx->saw_tstamp = 1; - opt_rx->rcv_tsval = ntohl(get_unaligned((__u32 *)ptr)); - opt_rx->rcv_tsecr = ntohl(get_unaligned((__u32 *)(ptr+4))); + opt_rx->rcv_tsval = ntohl(get_unaligned((__be32 *)ptr)); + opt_rx->rcv_tsecr = ntohl(get_unaligned((__be32 *)(ptr+4))); } } break; -- 0.99.9.GIT From nobody Mon Sep 17 00:00:00 2001 Subject: [PATCH] tcp_sock->pred_flags From: Al Viro Date: 1136537880 -0500 --- include/linux/tcp.h | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) 47e1d664f195478e696b3c7ea3458342e7d1dd25 diff --git a/include/linux/tcp.h b/include/linux/tcp.h index c02ab3e..4c2e663 100644 --- a/include/linux/tcp.h +++ b/include/linux/tcp.h @@ -232,7 +232,7 @@ struct tcp_sock { * Header prediction flags * 0x5?10 << 16 + snd_wnd in net byte order */ - __u32 pred_flags; + __be32 pred_flags; /* * RFC793 variables by their proper names. This means you can -- 0.99.9.GIT From nobody Mon Sep 17 00:00:00 2001 Subject: [PATCH] tcp_input.c misc2 From: Al Viro Date: 1136537897 -0500 --- net/ipv4/tcp_input.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) 9e7859ba3e2f9c24cd523ce2e4bd6762d6ee22ec diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index 8a0d2bc..1097dc8 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -2591,7 +2591,7 @@ static inline int tcp_fast_parse_options return 0; } else if (tp->rx_opt.tstamp_ok && th->doff == (sizeof(struct tcphdr)>>2)+(TCPOLEN_TSTAMP_ALIGNED>>2)) { - __u32 *ptr = (__u32 *)(th + 1); + __be32 *ptr = (__be32 *)(th + 1); if (*ptr == ntohl((TCPOPT_NOP << 24) | (TCPOPT_NOP << 16) | (TCPOPT_TIMESTAMP << 8) | TCPOLEN_TIMESTAMP)) { tp->rx_opt.saw_tstamp = 1; @@ -3764,7 +3764,7 @@ int tcp_rcv_established(struct sock *sk, /* Check timestamp */ if (tcp_header_len == sizeof(struct tcphdr) + TCPOLEN_TSTAMP_ALIGNED) { - __u32 *ptr = (__u32 *)(th + 1); + __be32 *ptr = (__be32 *)(th + 1); /* No? Slow path! */ if (*ptr != ntohl((TCPOPT_NOP << 24) | (TCPOPT_NOP << 16) -- 0.99.9.GIT From nobody Mon Sep 17 00:00:00 2001 Subject: [PATCH] tcp_input.c misc3 From: Al Viro Date: 1136540361 -0500 --- net/ipv4/tcp_input.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) 34d6e06005b78fae0bac3763567c6258348ebf71 diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index 1097dc8..a5ce608 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -2592,7 +2592,7 @@ static inline int tcp_fast_parse_options } else if (tp->rx_opt.tstamp_ok && th->doff == (sizeof(struct tcphdr)>>2)+(TCPOLEN_TSTAMP_ALIGNED>>2)) { __be32 *ptr = (__be32 *)(th + 1); - if (*ptr == ntohl((TCPOPT_NOP << 24) | (TCPOPT_NOP << 16) + if (*ptr == htonl((TCPOPT_NOP << 24) | (TCPOPT_NOP << 16) | (TCPOPT_TIMESTAMP << 8) | TCPOLEN_TIMESTAMP)) { tp->rx_opt.saw_tstamp = 1; ++ptr; @@ -3767,7 +3767,7 @@ int tcp_rcv_established(struct sock *sk, __be32 *ptr = (__be32 *)(th + 1); /* No? Slow path! */ - if (*ptr != ntohl((TCPOPT_NOP << 24) | (TCPOPT_NOP << 16) + if (*ptr != htonl((TCPOPT_NOP << 24) | (TCPOPT_NOP << 16) | (TCPOPT_TIMESTAMP << 8) | TCPOLEN_TIMESTAMP)) goto slow_path; -- 0.99.9.GIT From nobody Mon Sep 17 00:00:00 2001 Subject: [PATCH] ports in inet_sock From: Al Viro Date: 1136540384 -0500 --- include/linux/ip.h | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) fd1c34808ca8da36d78460678ddb71da5b0bce8e diff --git a/include/linux/ip.h b/include/linux/ip.h index bc57f0e..71b8d74 100644 --- a/include/linux/ip.h +++ b/include/linux/ip.h @@ -139,13 +139,13 @@ struct inet_sock { /* Socket demultiplex comparisons on incoming packets. */ __be32 daddr; /* Foreign IPv4 addr */ __be32 rcv_saddr; /* Bound local IPv4 addr */ - __u16 dport; /* Destination port */ + __be16 dport; /* Destination port */ __u16 num; /* Local port */ __be32 saddr; /* Sending source */ __s16 uc_ttl; /* Unicast TTL */ __u16 cmsg_flags; struct ip_options *opt; - __u16 sport; /* Source port */ + __be16 sport; /* Source port */ __u16 id; /* ID counter for DF pkts */ __u8 tos; /* TOS */ __u8 mc_ttl; /* Multicasting TTL */ -- 0.99.9.GIT From nobody Mon Sep 17 00:00:00 2001 Subject: [PATCH] struct flowi ip ports From: Al Viro Date: 1136540885 -0500 --- include/net/flow.h | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) 93e57bc9d1bcd619d90d0f0dabeae2eb0d0bd900 diff --git a/include/net/flow.h b/include/net/flow.h index 07d5d70..ae73979 100644 --- a/include/net/flow.h +++ b/include/net/flow.h @@ -54,8 +54,8 @@ struct flowi { #define FLOWI_FLAG_MULTIPATHOLDROUTE 0x01 union { struct { - __u16 sport; - __u16 dport; + __be16 sport; + __be16 dport; } ports; struct { -- 0.99.9.GIT From nobody Mon Sep 17 00:00:00 2001 Subject: [PATCH] sin_port From: Al Viro Date: 1136541618 -0500 --- include/linux/in.h | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) 2e8b612b80e47c12e6607f5f7c5d618bc26e85cb diff --git a/include/linux/in.h b/include/linux/in.h index 4e9b24d..07c0d40 100644 --- a/include/linux/in.h +++ b/include/linux/in.h @@ -176,7 +176,7 @@ struct in_pktinfo #define __SOCK_SIZE__ 16 /* sizeof(struct sockaddr) */ struct sockaddr_in { sa_family_t sin_family; /* Address family */ - unsigned short int sin_port; /* Port number */ + __be16 sin_port; /* Port number */ struct in_addr sin_addr; /* Internet address */ /* Pad to size of `struct sockaddr'. */ -- 0.99.9.GIT From nobody Mon Sep 17 00:00:00 2001 Subject: [PATCH] ip_route_connect() port arguments From: Al Viro Date: 1136541725 -0500 --- include/net/route.h | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) 00207f521cfdab20f10dccdea71479d7bc30deef diff --git a/include/net/route.h b/include/net/route.h index 3df36a0..330542c 100644 --- a/include/net/route.h +++ b/include/net/route.h @@ -146,7 +146,7 @@ static inline char rt_tos2priority(u8 to static inline int ip_route_connect(struct rtable **rp, __be32 dst, __be32 src, u32 tos, int oif, u8 protocol, - u16 sport, u16 dport, struct sock *sk) + __be16 sport, __be16 dport, struct sock *sk) { struct flowi fl = { .oif = oif, .nl_u = { .ip4_u = { .daddr = dst, -- 0.99.9.GIT From nobody Mon Sep 17 00:00:00 2001 Subject: [PATCH] ip_route_newports From: Al Viro Date: 1136542170 -0500 --- include/net/route.h | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) e1f5bce7f7db0236792bed13be8e90954c916c0b diff --git a/include/net/route.h b/include/net/route.h index 330542c..f03cc5f 100644 --- a/include/net/route.h +++ b/include/net/route.h @@ -170,7 +170,7 @@ static inline int ip_route_connect(struc return ip_route_output_flow(rp, &fl, sk, 0); } -static inline int ip_route_newports(struct rtable **rp, u16 sport, u16 dport, +static inline int ip_route_newports(struct rtable **rp, __be16 sport, __be16 dport, struct sock *sk) { if (sport != (*rp)->fl.fl_ip_sport || -- 0.99.9.GIT From nobody Mon Sep 17 00:00:00 2001 Subject: [PATCH] ip_local_error() port argument From: Al Viro Date: 1136542271 -0500 --- include/net/ip.h | 4 ++-- net/ipv4/ip_sockglue.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) bd441dd09414199c63a8b03e9b4b1ee33a5cdb2f diff --git a/include/net/ip.h b/include/net/ip.h index 91e2d35..549639b 100644 --- a/include/net/ip.h +++ b/include/net/ip.h @@ -356,8 +356,8 @@ extern int ip_ra_control(struct sock *sk extern int ip_recv_error(struct sock *sk, struct msghdr *msg, int len); extern void ip_icmp_error(struct sock *sk, struct sk_buff *skb, int err, u16 port, u32 info, u8 *payload); -extern void ip_local_error(struct sock *sk, int err, __be32 daddr, u16 dport, - u32 info); +extern void ip_local_error(struct sock *sk, int err, __be32 daddr, __be16 dport, + __be32 info); /* sysctl helpers - any sysctl which holds a value that ends up being * fed into the routing cache should use these handlers. diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c index 400337c..635da18 100644 --- a/net/ipv4/ip_sockglue.c +++ b/net/ipv4/ip_sockglue.c @@ -260,7 +260,7 @@ void ip_icmp_error(struct sock *sk, stru kfree_skb(skb); } -void ip_local_error(struct sock *sk, int err, __be32 daddr, u16 port, u32 info) +void ip_local_error(struct sock *sk, int err, __be32 daddr, __be16 port, u32 info) { struct inet_sock *inet = inet_sk(sk); struct sock_exterr_skb *serr; -- 0.99.9.GIT From nobody Mon Sep 17 00:00:00 2001 Subject: [PATCH] fix a typo in ip_local_err() patch From: Al Viro Date: 1136542670 -0500 --- include/net/ip.h | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) bb0ddbcedb37a75aa81a75c5f886a93e64496e0e diff --git a/include/net/ip.h b/include/net/ip.h index 549639b..95259d9 100644 --- a/include/net/ip.h +++ b/include/net/ip.h @@ -357,7 +357,7 @@ extern int ip_recv_error(struct sock *s extern void ip_icmp_error(struct sock *sk, struct sk_buff *skb, int err, u16 port, u32 info, u8 *payload); extern void ip_local_error(struct sock *sk, int err, __be32 daddr, __be16 dport, - __be32 info); + u32 info); /* sysctl helpers - any sysctl which holds a value that ends up being * fed into the routing cache should use these handlers. -- 0.99.9.GIT From nobody Mon Sep 17 00:00:00 2001 Subject: [PATCH] sock_exterr_skb From: Al Viro Date: 1136543047 -0500 --- include/linux/errqueue.h | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) cc081ee6310c0475933ed57c411fa3e00e2409b4 diff --git a/include/linux/errqueue.h b/include/linux/errqueue.h index 174582f..14f77f0 100644 --- a/include/linux/errqueue.h +++ b/include/linux/errqueue.h @@ -39,7 +39,7 @@ struct sock_exterr_skb } header; struct sock_extended_err ee; u16 addr_offset; - u16 port; + __be16 port; }; #endif -- 0.99.9.GIT From nobody Mon Sep 17 00:00:00 2001 Subject: [PATCH] tcp_output.c From: Al Viro Date: 1136543531 -0500 --- include/net/tcp.h | 4 ++-- net/ipv4/tcp_output.c | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) 95c82214a87dd30defc86ad39a114690a79e62b4 diff --git a/include/net/tcp.h b/include/net/tcp.h index d78025f..0d61ceb 100644 --- a/include/net/tcp.h +++ b/include/net/tcp.h @@ -1025,7 +1025,7 @@ static __inline__ void tcp_sack_reset(st rx_opt->num_sacks = 0; } -static __inline__ void tcp_build_and_update_options(__u32 *ptr, struct tcp_sock *tp, __u32 tstamp) +static __inline__ void tcp_build_and_update_options(__be32 *ptr, struct tcp_sock *tp, __u32 tstamp) { if (tp->rx_opt.tstamp_ok) { *ptr++ = __constant_htonl((TCPOPT_NOP << 24) | @@ -1060,7 +1060,7 @@ static __inline__ void tcp_build_and_upd * MAX_SYN_SIZE to match the new maximum number of options that you * can generate. */ -static inline void tcp_syn_build_options(__u32 *ptr, int mss, int ts, int sack, +static inline void tcp_syn_build_options(__be32 *ptr, int mss, int ts, int sack, int offer_wscale, int wscale, __u32 tstamp, __u32 ts_recent) { /* We always get an MSS option. diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c index b7325e0..746fd24 100644 --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c @@ -336,7 +336,7 @@ static int tcp_transmit_skb(struct sock th->dest = inet->dport; th->seq = htonl(tcb->seq); th->ack_seq = htonl(tp->rcv_nxt); - *(((__u16 *)th) + 6) = htons(((tcp_header_size >> 2) << 12) | + *(((__be16 *)th) + 6) = htons(((tcp_header_size >> 2) << 12) | tcb->flags); if (unlikely(tcb->flags & TCPCB_FLAG_SYN)) { @@ -357,7 +357,7 @@ static int tcp_transmit_skb(struct sock } if (unlikely(tcb->flags & TCPCB_FLAG_SYN)) { - tcp_syn_build_options((__u32 *)(th + 1), + tcp_syn_build_options((__be32 *)(th + 1), tcp_advertise_mss(sk), (sysctl_flags & SYSCTL_FLAG_TSTAMPS), (sysctl_flags & SYSCTL_FLAG_SACK), @@ -366,7 +366,7 @@ static int tcp_transmit_skb(struct sock tcb->when, tp->rx_opt.ts_recent); } else { - tcp_build_and_update_options((__u32 *)(th + 1), + tcp_build_and_update_options((__be32 *)(th + 1), tp, tcb->when); TCP_ECN_send(sk, tp, skb, tcp_header_size); } @@ -1779,7 +1779,7 @@ struct sk_buff * tcp_make_synack(struct th->window = htons(req->rcv_wnd); TCP_SKB_CB(skb)->when = tcp_time_stamp; - tcp_syn_build_options((__u32 *)(th + 1), dst_metric(dst, RTAX_ADVMSS), ireq->tstamp_ok, + tcp_syn_build_options((__be32 *)(th + 1), dst_metric(dst, RTAX_ADVMSS), ireq->tstamp_ok, ireq->sack_ok, ireq->wscale_ok, ireq->rcv_wscale, TCP_SKB_CB(skb)->when, req->ts_recent); -- 0.99.9.GIT From nobody Mon Sep 17 00:00:00 2001 Subject: [PATCH] inet_request_sock port From: Al Viro Date: 1136544240 -0500 --- include/linux/ip.h | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) f3bfb27c48cbd285e6f8bf6700885616f3c5df10 diff --git a/include/linux/ip.h b/include/linux/ip.h index 71b8d74..1a7c27b 100644 --- a/include/linux/ip.h +++ b/include/linux/ip.h @@ -112,7 +112,7 @@ struct inet_request_sock { struct request_sock req; __be32 loc_addr; __be32 rmt_addr; - u16 rmt_port; + __be16 rmt_port; u16 snd_wscale : 4, rcv_wscale : 4, tstamp_ok : 1, -- 0.99.9.GIT From nobody Mon Sep 17 00:00:00 2001 Subject: [PATCH] arphdr From: Al Viro Date: 1136544725 -0500 --- include/linux/if_arp.h | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) 39695705b41d4711d5efeccc3ffb544eb11b58f3 diff --git a/include/linux/if_arp.h b/include/linux/if_arp.h index a8b1a20..7f57142 100644 --- a/include/linux/if_arp.h +++ b/include/linux/if_arp.h @@ -130,11 +130,11 @@ struct arpreq_old { struct arphdr { - unsigned short ar_hrd; /* format of hardware address */ - unsigned short ar_pro; /* format of protocol address */ + __be16 ar_hrd; /* format of hardware address */ + __be16 ar_pro; /* format of protocol address */ unsigned char ar_hln; /* length of hardware address */ unsigned char ar_pln; /* length of protocol address */ - unsigned short ar_op; /* ARP opcode (command) */ + __be16 ar_op; /* ARP opcode (command) */ #if 0 /* -- 0.99.9.GIT From nobody Mon Sep 17 00:00:00 2001 Subject: [PATCH] arp.c From: Al Viro Date: 1136545928 -0500 --- include/net/arp.h | 8 ++++---- net/bridge/netfilter/ebt_arpreply.c | 2 +- net/ipv4/arp.c | 34 +++++++++++++++++----------------- 3 files changed, 22 insertions(+), 22 deletions(-) c12abe3545b7a3f46b85e8e8807a1d69d4e69a2b diff --git a/include/net/arp.h b/include/net/arp.h index a13e30c..1bda18c 100644 --- a/include/net/arp.h +++ b/include/net/arp.h @@ -14,15 +14,15 @@ extern int arp_rcv(struct sk_buff *skb, struct packet_type *pt, struct net_device *orig_dev); extern int arp_find(unsigned char *haddr, struct sk_buff *skb); extern int arp_ioctl(unsigned int cmd, void __user *arg); -extern void arp_send(int type, int ptype, u32 dest_ip, - struct net_device *dev, u32 src_ip, +extern void arp_send(int type, int ptype, __be32 dest_ip, + struct net_device *dev, __be32 src_ip, unsigned char *dest_hw, unsigned char *src_hw, unsigned char *th); extern int arp_bind_neighbour(struct dst_entry *dst); extern int arp_mc_map(u32 addr, u8 *haddr, struct net_device *dev, int dir); extern void arp_ifdown(struct net_device *dev); -extern struct sk_buff *arp_create(int type, int ptype, u32 dest_ip, - struct net_device *dev, u32 src_ip, +extern struct sk_buff *arp_create(int type, int ptype, __be32 dest_ip, + struct net_device *dev, __be32 src_ip, unsigned char *dest_hw, unsigned char *src_hw, unsigned char *target_hw); extern void arp_xmit(struct sk_buff *skb); diff --git a/net/bridge/netfilter/ebt_arpreply.c b/net/bridge/netfilter/ebt_arpreply.c index b934de9..3d817ca 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_bu const void *data, unsigned int datalen) { struct ebt_arpreply_info *info = (struct ebt_arpreply_info *)data; - u32 _sip, *siptr, _dip, *diptr; + __be32 _sip, *siptr, _dip, *diptr; struct arphdr _ah, *ap; unsigned char _sha[ETH_ALEN], *shp; struct sk_buff *skb = *pskb; diff --git a/net/ipv4/arp.c b/net/ipv4/arp.c index 27b5a45..b4389dc 100644 --- a/net/ipv4/arp.c +++ b/net/ipv4/arp.c @@ -233,7 +233,7 @@ static u32 arp_hash(const void *pkey, co static int arp_constructor(struct neighbour *neigh) { - __be32 addr = *(u32*)neigh->primary_key; + __be32 addr = *(__be32*)neigh->primary_key; struct net_device *dev = neigh->dev; struct in_device *in_dev; struct neigh_parms *parms; @@ -332,7 +332,7 @@ static void arp_solicit(struct neighbour __be32 saddr = 0; u8 *dst_ha = NULL; struct net_device *dev = neigh->dev; - __be32 target = *(u32*)neigh->primary_key; + __be32 target = *(__be32*)neigh->primary_key; int probes = atomic_read(&neigh->probes); struct in_device *in_dev = in_dev_get(dev); @@ -384,7 +384,7 @@ static void arp_solicit(struct neighbour } static int arp_ignore(struct in_device *in_dev, struct net_device *dev, - u32 sip, u32 tip) + __be32 sip, __be32 tip) { int scope; @@ -419,7 +419,7 @@ static int arp_ignore(struct in_device * return !inet_confirm_addr(dev, sip, tip, scope); } -static int arp_filter(__u32 sip, __u32 tip, struct net_device *dev) +static int arp_filter(__be32 sip, __be32 tip, struct net_device *dev) { struct flowi fl = { .nl_u = { .ip4_u = { .daddr = sip, .saddr = tip } } }; @@ -448,7 +448,7 @@ static int arp_filter(__u32 sip, __u32 t * is allowed to use this function, it is scheduled to be removed. --ANK */ -static int arp_set_predefined(int addr_hint, unsigned char * haddr, u32 paddr, struct net_device * dev) +static int arp_set_predefined(int addr_hint, unsigned char * haddr, __be32 paddr, struct net_device * dev) { switch (addr_hint) { case RTN_LOCAL: @@ -510,7 +510,7 @@ int arp_bind_neighbour(struct dst_entry if (dev == NULL) return -EINVAL; if (n == NULL) { - u32 nexthop = ((struct rtable*)dst)->rt_gateway; + __be32 nexthop = ((struct rtable*)dst)->rt_gateway; if (dev->flags&(IFF_LOOPBACK|IFF_POINTOPOINT)) nexthop = 0; n = __neigh_lookup_errno( @@ -559,8 +559,8 @@ static inline int arp_fwd_proxy(struct i * Create an arp packet. If (dest_hw == NULL), we create a broadcast * message. */ -struct sk_buff *arp_create(int type, int ptype, u32 dest_ip, - struct net_device *dev, u32 src_ip, +struct sk_buff *arp_create(int type, int ptype, __be32 dest_ip, + struct net_device *dev, __be32 src_ip, unsigned char *dest_hw, unsigned char *src_hw, unsigned char *target_hw) { @@ -674,8 +674,8 @@ void arp_xmit(struct sk_buff *skb) /* * Create and send an arp packet. */ -void arp_send(int type, int ptype, u32 dest_ip, - struct net_device *dev, u32 src_ip, +void arp_send(int type, int ptype, __be32 dest_ip, + struct net_device *dev, __be32 src_ip, unsigned char *dest_hw, unsigned char *src_hw, unsigned char *target_hw) { @@ -967,13 +967,13 @@ out_of_mem: static int arp_req_set(struct arpreq *r, struct net_device * dev) { - u32 ip = ((struct sockaddr_in *) &r->arp_pa)->sin_addr.s_addr; + __be32 ip = ((struct sockaddr_in *) &r->arp_pa)->sin_addr.s_addr; struct neighbour *neigh; int err; if (r->arp_flags&ATF_PUBL) { - u32 mask = ((struct sockaddr_in *) &r->arp_netmask)->sin_addr.s_addr; - if (mask && mask != 0xFFFFFFFF) + __be32 mask = ((struct sockaddr_in *) &r->arp_netmask)->sin_addr.s_addr; + if (mask && mask != htonl(0xFFFFFFFF)) return -EINVAL; if (!dev && (r->arp_flags & ATF_COM)) { dev = dev_getbyhwaddr(r->arp_ha.sa_family, r->arp_ha.sa_data); @@ -1061,7 +1061,7 @@ static unsigned arp_state_to_flags(struc static int arp_req_get(struct arpreq *r, struct net_device *dev) { - u32 ip = ((struct sockaddr_in *) &r->arp_pa)->sin_addr.s_addr; + __be32 ip = ((struct sockaddr_in *) &r->arp_pa)->sin_addr.s_addr; struct neighbour *neigh; int err = -ENXIO; @@ -1082,13 +1082,13 @@ static int arp_req_get(struct arpreq *r, static int arp_req_delete(struct arpreq *r, struct net_device * dev) { int err; - u32 ip = ((struct sockaddr_in *)&r->arp_pa)->sin_addr.s_addr; + __be32 ip = ((struct sockaddr_in *)&r->arp_pa)->sin_addr.s_addr; struct neighbour *neigh; if (r->arp_flags & ATF_PUBL) { - u32 mask = + __be32 mask = ((struct sockaddr_in *)&r->arp_netmask)->sin_addr.s_addr; - if (mask == 0xFFFFFFFF) + if (mask == htonl(0xFFFFFFFF)) return pneigh_delete(&arp_tbl, &ip, dev); if (mask == 0) { if (dev == NULL) { -- 0.99.9.GIT From nobody Mon Sep 17 00:00:00 2001 Subject: [PATCH] trivial parts of ipv4/netfilter From: Al Viro Date: 1136553636 -0500 --- include/linux/netfilter_arp/arp_tables.h | 6 +- include/linux/netfilter_ipv4/ip_conntrack_tuple.h | 10 +-- include/linux/netfilter_ipv4/ip_nat.h | 2 - include/linux/netfilter_ipv4/ipt_iprange.h | 2 - net/ipv4/netfilter/arp_tables.c | 2 - net/ipv4/netfilter/ip_conntrack_amanda.c | 6 +- net/ipv4/netfilter/ip_conntrack_core.c | 4 + net/ipv4/netfilter/ip_conntrack_ftp.c | 6 +- net/ipv4/netfilter/ip_conntrack_helper_pptp.c | 4 + net/ipv4/netfilter/ip_conntrack_irc.c | 5 + net/ipv4/netfilter/ip_conntrack_netbios_ns.c | 6 +- net/ipv4/netfilter/ip_conntrack_netlink.c | 82 +++++++++++---------- net/ipv4/netfilter/ip_conntrack_proto_sctp.c | 2 - net/ipv4/netfilter/ip_conntrack_proto_tcp.c | 6 +- net/ipv4/netfilter/ip_nat_core.c | 10 +-- net/ipv4/netfilter/ip_nat_ftp.c | 10 +-- net/ipv4/netfilter/ip_nat_helper_pptp.c | 6 +- net/ipv4/netfilter/ip_nat_proto_gre.c | 4 + net/ipv4/netfilter/ip_nat_proto_tcp.c | 12 ++- net/ipv4/netfilter/ip_nat_rule.c | 6 +- net/ipv4/netfilter/ip_nat_standalone.c | 4 + net/ipv4/netfilter/ipt_CLUSTERIP.c | 10 +-- net/ipv4/netfilter/ipt_DSCP.c | 6 +- net/ipv4/netfilter/ipt_ECN.c | 12 ++- net/ipv4/netfilter/ipt_NETMAP.c | 2 - net/ipv4/netfilter/ipt_REDIRECT.c | 2 - net/ipv4/netfilter/ipt_REJECT.c | 4 + net/ipv4/netfilter/ipt_SAME.c | 3 + net/ipv4/netfilter/ipt_TCPMSS.c | 15 ++-- net/ipv4/netfilter/ipt_TOS.c | 6 +- net/ipv4/netfilter/ipt_TTL.c | 4 + net/ipv4/netfilter/ipt_hashlimit.c | 18 +++-- net/ipv4/netfilter/ipt_multiport.c | 4 + net/ipv4/netfilter/ipt_recent.c | 18 +++-- net/ipv4/netfilter/ipt_sctp.c | 2 - net/ipv4/netfilter/iptable_mangle.c | 2 - 36 files changed, 157 insertions(+), 146 deletions(-) b9e78e5a6d429ea66167eb316a32fff4194ef789 diff --git a/include/linux/netfilter_arp/arp_tables.h b/include/linux/netfilter_arp/arp_tables.h index e98a870..f8d508d 100644 --- a/include/linux/netfilter_arp/arp_tables.h +++ b/include/linux/netfilter_arp/arp_tables.h @@ -42,11 +42,11 @@ struct arpt_arp { struct arpt_devaddr_info tgt_devaddr; /* ARP operation code. */ - u_int16_t arpop, arpop_mask; + __be16 arpop, arpop_mask; /* ARP hardware address and protocol address format. */ - u_int16_t arhrd, arhrd_mask; - u_int16_t arpro, arpro_mask; + __be16 arhrd, arhrd_mask; + __be16 arpro, arpro_mask; /* The protocol address length is only accepted if it is 4 * so there is no use in offering a way to do filtering on it. diff --git a/include/linux/netfilter_ipv4/ip_conntrack_tuple.h b/include/linux/netfilter_ipv4/ip_conntrack_tuple.h index 2fdabdb..82b082a 100644 --- a/include/linux/netfilter_ipv4/ip_conntrack_tuple.h +++ b/include/linux/netfilter_ipv4/ip_conntrack_tuple.h @@ -29,7 +29,7 @@ union ip_conntrack_manip_proto u_int16_t id; } icmp; struct { - u_int16_t port; + __be16 port; } sctp; struct { __be16 key; /* key is 32bit, pptp only uses 16 */ @@ -39,7 +39,7 @@ union ip_conntrack_manip_proto /* The manipulable part of the tuple. */ struct ip_conntrack_manip { - u_int32_t ip; + __be32 ip; union ip_conntrack_manip_proto u; }; @@ -50,13 +50,13 @@ struct ip_conntrack_tuple /* These are the parts of the tuple which are fixed. */ struct { - u_int32_t ip; + __be32 ip; union { /* Add other protocols here. */ u_int16_t all; struct { - u_int16_t port; + __be16 port; } tcp; struct { u_int16_t port; @@ -65,7 +65,7 @@ struct ip_conntrack_tuple u_int8_t type, code; } icmp; struct { - u_int16_t port; + __be16 port; } sctp; struct { __be16 key; /* key is 32bit, diff --git a/include/linux/netfilter_ipv4/ip_nat.h b/include/linux/netfilter_ipv4/ip_nat.h index 41a107d..400731e 100644 --- a/include/linux/netfilter_ipv4/ip_nat.h +++ b/include/linux/netfilter_ipv4/ip_nat.h @@ -33,7 +33,7 @@ struct ip_nat_range unsigned int flags; /* Inclusive: network order. */ - u_int32_t min_ip, max_ip; + __be32 min_ip, max_ip; /* Inclusive: network order */ union ip_conntrack_manip_proto min, max; diff --git a/include/linux/netfilter_ipv4/ipt_iprange.h b/include/linux/netfilter_ipv4/ipt_iprange.h index 3ecb3bd..34ab0fb 100644 --- a/include/linux/netfilter_ipv4/ipt_iprange.h +++ b/include/linux/netfilter_ipv4/ipt_iprange.h @@ -8,7 +8,7 @@ struct ipt_iprange { /* Inclusive: network order. */ - u_int32_t min_ip, max_ip; + __be32 min_ip, max_ip; }; struct ipt_iprange_info diff --git a/net/ipv4/netfilter/arp_tables.c b/net/ipv4/netfilter/arp_tables.c index 3c2e963..0e430aa 100644 --- a/net/ipv4/netfilter/arp_tables.c +++ b/net/ipv4/netfilter/arp_tables.c @@ -105,7 +105,7 @@ static inline int arp_packet_match(const { char *arpptr = (char *)(arphdr + 1); char *src_devaddr, *tgt_devaddr; - u32 src_ipaddr, tgt_ipaddr; + __be32 src_ipaddr, tgt_ipaddr; int i, ret; #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 e52847f..dfd65f8 100644 --- a/net/ipv4/netfilter/ip_conntrack_amanda.c +++ b/net/ipv4/netfilter/ip_conntrack_amanda.c @@ -116,11 +116,11 @@ static int help(struct sk_buff **pskb, exp->tuple.dst.protonum = IPPROTO_TCP; exp->tuple.dst.u.tcp.port = htons(port); - exp->mask.src.ip = 0xFFFFFFFF; + exp->mask.src.ip = htonl(0xFFFFFFFF); exp->mask.src.u.tcp.port = 0; - exp->mask.dst.ip = 0xFFFFFFFF; + exp->mask.dst.ip = htonl(0xFFFFFFFF); exp->mask.dst.protonum = 0xFF; - exp->mask.dst.u.tcp.port = 0xFFFF; + exp->mask.dst.u.tcp.port = htons(0xFFFF); if (ip_nat_amanda_hook) ret = ip_nat_amanda_hook(pskb, ctinfo, diff --git a/net/ipv4/netfilter/ip_conntrack_core.c b/net/ipv4/netfilter/ip_conntrack_core.c index 84c66db..36e4f20 100644 --- a/net/ipv4/netfilter/ip_conntrack_core.c +++ b/net/ipv4/netfilter/ip_conntrack_core.c @@ -151,8 +151,8 @@ static unsigned int ip_conntrack_hash_rn static u_int32_t __hash_conntrack(const struct ip_conntrack_tuple *tuple, unsigned int size, unsigned int rnd) { - return (jhash_3words(tuple->src.ip, - (tuple->dst.ip ^ tuple->dst.protonum), + return (jhash_3words((__force u32)tuple->src.ip, + ((__force u32)tuple->dst.ip ^ tuple->dst.protonum), (tuple->src.u.all | (tuple->dst.u.all << 16)), rnd) % size); } diff --git a/net/ipv4/netfilter/ip_conntrack_ftp.c b/net/ipv4/netfilter/ip_conntrack_ftp.c index 68b173b..a9b5f58 100644 --- a/net/ipv4/netfilter/ip_conntrack_ftp.c +++ b/net/ipv4/netfilter/ip_conntrack_ftp.c @@ -417,8 +417,8 @@ static int help(struct sk_buff **pskb, exp->tuple.src.u.tcp.port = 0; /* Don't care. */ exp->tuple.dst.protonum = IPPROTO_TCP; exp->mask = ((struct ip_conntrack_tuple) - { { 0xFFFFFFFF, { 0 } }, - { 0xFFFFFFFF, { .tcp = { 0xFFFF } }, 0xFF }}); + { { htonl(0xFFFFFFFF), { 0 } }, + { htonl(0xFFFFFFFF), { .tcp = { htons(0xFFFF) } }, 0xFF }}); exp->expectfn = NULL; exp->flags = 0; @@ -480,7 +480,7 @@ static int __init init(void) for (i = 0; i < ports_c; i++) { ftp[i].tuple.src.u.tcp.port = htons(ports[i]); ftp[i].tuple.dst.protonum = IPPROTO_TCP; - ftp[i].mask.src.u.tcp.port = 0xFFFF; + ftp[i].mask.src.u.tcp.port = htons(0xFFFF); ftp[i].mask.dst.protonum = 0xFF; ftp[i].max_expected = 1; ftp[i].timeout = 5 * 60; /* 5 minutes */ diff --git a/net/ipv4/netfilter/ip_conntrack_helper_pptp.c b/net/ipv4/netfilter/ip_conntrack_helper_pptp.c index 4108a5e..62ffc4b 100644 --- a/net/ipv4/netfilter/ip_conntrack_helper_pptp.c +++ b/net/ipv4/netfilter/ip_conntrack_helper_pptp.c @@ -259,11 +259,11 @@ exp_gre(struct ip_conntrack *master, memcpy(&exp_orig->tuple, &exp_tuples[0], sizeof(exp_orig->tuple)); - exp_orig->mask.src.ip = 0xffffffff; + exp_orig->mask.src.ip = htonl(0xffffffff); exp_orig->mask.src.u.all = 0; exp_orig->mask.dst.u.all = 0; exp_orig->mask.dst.u.gre.key = htons(0xffff); - exp_orig->mask.dst.ip = 0xffffffff; + exp_orig->mask.dst.ip = htonl(0xffffffff); exp_orig->mask.dst.protonum = 0xff; exp_orig->master = master; diff --git a/net/ipv4/netfilter/ip_conntrack_irc.c b/net/ipv4/netfilter/ip_conntrack_irc.c index d7c4042..bd34945 100644 --- a/net/ipv4/netfilter/ip_conntrack_irc.c +++ b/net/ipv4/netfilter/ip_conntrack_irc.c @@ -219,7 +219,8 @@ static int help(struct sk_buff **pskb, IPPROTO_TCP }}); exp->mask = ((struct ip_conntrack_tuple) { { 0, { 0 } }, - { 0xFFFFFFFF, { .tcp = { 0xFFFF } }, 0xFF }}); + { htonl(0xFFFFFFFF), + { .tcp = { htons(0xFFFF) } }, 0xFF }}); exp->expectfn = NULL; exp->flags = 0; if (ip_nat_irc_hook) @@ -271,7 +272,7 @@ static int __init init(void) hlpr = &irc_helpers[i]; hlpr->tuple.src.u.tcp.port = htons(ports[i]); hlpr->tuple.dst.protonum = IPPROTO_TCP; - hlpr->mask.src.u.tcp.port = 0xFFFF; + hlpr->mask.src.u.tcp.port = htons(0xFFFF); hlpr->mask.dst.protonum = 0xFF; hlpr->max_expected = max_dcc_channels; 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 186646e..abcef4d 100644 --- a/net/ipv4/netfilter/ip_conntrack_netbios_ns.c +++ b/net/ipv4/netfilter/ip_conntrack_netbios_ns.c @@ -47,7 +47,7 @@ static int help(struct sk_buff **pskb, struct iphdr *iph = (*pskb)->nh.iph; struct rtable *rt = (struct rtable *)(*pskb)->dst; struct in_device *in_dev; - u_int32_t mask = 0; + __be32 mask = 0; /* we're only interested in locally generated packets */ if ((*pskb)->sk == NULL) @@ -77,11 +77,11 @@ static int help(struct sk_buff **pskb, goto out; exp->tuple = ct->tuplehash[IP_CT_DIR_REPLY].tuple; - exp->tuple.src.u.udp.port = ntohs(NMBD_PORT); + exp->tuple.src.u.udp.port = htons(NMBD_PORT); exp->mask.src.ip = mask; exp->mask.src.u.udp.port = 0xFFFF; - exp->mask.dst.ip = 0xFFFFFFFF; + exp->mask.dst.ip = htonl(0xFFFFFFFF); exp->mask.dst.u.udp.port = 0xFFFF; exp->mask.dst.protonum = 0xFF; diff --git a/net/ipv4/netfilter/ip_conntrack_netlink.c b/net/ipv4/netfilter/ip_conntrack_netlink.c index 91fe8f2..9c0ae9b 100644 --- a/net/ipv4/netfilter/ip_conntrack_netlink.c +++ b/net/ipv4/netfilter/ip_conntrack_netlink.c @@ -81,8 +81,8 @@ ctnetlink_dump_tuples(struct sk_buff *sk struct nfattr *nest_parms; nest_parms = NFA_NEST(skb, CTA_TUPLE_IP); - NFA_PUT(skb, CTA_IP_V4_SRC, sizeof(u_int32_t), &tuple->src.ip); - NFA_PUT(skb, CTA_IP_V4_DST, sizeof(u_int32_t), &tuple->dst.ip); + NFA_PUT(skb, CTA_IP_V4_SRC, sizeof(__be32), &tuple->src.ip); + NFA_PUT(skb, CTA_IP_V4_DST, sizeof(__be32), &tuple->dst.ip); NFA_NEST_END(skb, nest_parms); nest_parms = NFA_NEST(skb, CTA_TUPLE_PROTO); @@ -98,7 +98,7 @@ nfattr_failure: static inline int ctnetlink_dump_status(struct sk_buff *skb, const struct ip_conntrack *ct) { - u_int32_t status = htonl((u_int32_t) ct->status); + __be32 status = htonl((u_int32_t) ct->status); NFA_PUT(skb, CTA_STATUS, sizeof(status), &status); return 0; @@ -110,7 +110,7 @@ static inline int ctnetlink_dump_timeout(struct sk_buff *skb, const struct ip_conntrack *ct) { long timeout_l = ct->timeout.expires - jiffies; - u_int32_t timeout; + __be32 timeout; if (timeout_l < 0) timeout = 0; @@ -180,13 +180,13 @@ ctnetlink_dump_counters(struct sk_buff * { enum ctattr_type type = dir ? CTA_COUNTERS_REPLY: CTA_COUNTERS_ORIG; struct nfattr *nest_count = NFA_NEST(skb, type); - u_int32_t tmp; + __be32 tmp; tmp = htonl(ct->counters[dir].packets); - NFA_PUT(skb, CTA_COUNTERS32_PACKETS, sizeof(u_int32_t), &tmp); + NFA_PUT(skb, CTA_COUNTERS32_PACKETS, sizeof(__be32), &tmp); tmp = htonl(ct->counters[dir].bytes); - NFA_PUT(skb, CTA_COUNTERS32_BYTES, sizeof(u_int32_t), &tmp); + NFA_PUT(skb, CTA_COUNTERS32_BYTES, sizeof(__be32), &tmp); NFA_NEST_END(skb, nest_count); @@ -203,9 +203,9 @@ nfattr_failure: static inline int ctnetlink_dump_mark(struct sk_buff *skb, const struct ip_conntrack *ct) { - u_int32_t mark = htonl(ct->mark); + __be32 mark = htonl(ct->mark); - NFA_PUT(skb, CTA_MARK, sizeof(u_int32_t), &mark); + NFA_PUT(skb, CTA_MARK, sizeof(__be32), &mark); return 0; nfattr_failure: @@ -218,8 +218,8 @@ nfattr_failure: static inline int ctnetlink_dump_id(struct sk_buff *skb, const struct ip_conntrack *ct) { - u_int32_t id = htonl(ct->id); - NFA_PUT(skb, CTA_ID, sizeof(u_int32_t), &id); + __be32 id = htonl(ct->id); + NFA_PUT(skb, CTA_ID, sizeof(__be32), &id); return 0; nfattr_failure: @@ -229,9 +229,9 @@ nfattr_failure: static inline int ctnetlink_dump_use(struct sk_buff *skb, const struct ip_conntrack *ct) { - unsigned int use = htonl(atomic_read(&ct->ct_general.use)); + __be32 use = htonl(atomic_read(&ct->ct_general.use)); - NFA_PUT(skb, CTA_USE, sizeof(u_int32_t), &use); + NFA_PUT(skb, CTA_USE, sizeof(__be32), &use); return 0; nfattr_failure: @@ -473,8 +473,8 @@ out: #endif static const size_t cta_min_ip[CTA_IP_MAX] = { - [CTA_IP_V4_SRC-1] = sizeof(u_int32_t), - [CTA_IP_V4_DST-1] = sizeof(u_int32_t), + [CTA_IP_V4_SRC-1] = sizeof(__be32), + [CTA_IP_V4_DST-1] = sizeof(__be32), }; static inline int @@ -491,11 +491,11 @@ ctnetlink_parse_tuple_ip(struct nfattr * if (!tb[CTA_IP_V4_SRC-1]) return -EINVAL; - tuple->src.ip = *(u_int32_t *)NFA_DATA(tb[CTA_IP_V4_SRC-1]); + tuple->src.ip = *(__be32 *)NFA_DATA(tb[CTA_IP_V4_SRC-1]); if (!tb[CTA_IP_V4_DST-1]) return -EINVAL; - tuple->dst.ip = *(u_int32_t *)NFA_DATA(tb[CTA_IP_V4_DST-1]); + tuple->dst.ip = *(__be32 *)NFA_DATA(tb[CTA_IP_V4_DST-1]); DEBUGP("leaving\n"); @@ -618,8 +618,8 @@ static int ctnetlink_parse_nat_proto(str } static const size_t cta_min_nat[CTA_NAT_MAX] = { - [CTA_NAT_MINIP-1] = sizeof(u_int32_t), - [CTA_NAT_MAXIP-1] = sizeof(u_int32_t), + [CTA_NAT_MINIP-1] = sizeof(__be32), + [CTA_NAT_MAXIP-1] = sizeof(__be32), }; static inline int @@ -639,12 +639,12 @@ ctnetlink_parse_nat(struct nfattr *cda[] return -EINVAL; if (tb[CTA_NAT_MINIP-1]) - range->min_ip = *(u_int32_t *)NFA_DATA(tb[CTA_NAT_MINIP-1]); + range->min_ip = *(__be32 *)NFA_DATA(tb[CTA_NAT_MINIP-1]); if (!tb[CTA_NAT_MAXIP-1]) range->max_ip = range->min_ip; else - range->max_ip = *(u_int32_t *)NFA_DATA(tb[CTA_NAT_MAXIP-1]); + range->max_ip = *(__be32 *)NFA_DATA(tb[CTA_NAT_MAXIP-1]); if (range->min_ip) range->flags |= IP_NAT_RANGE_MAP_IPS; @@ -679,11 +679,11 @@ ctnetlink_parse_help(struct nfattr *attr } static const size_t cta_min[CTA_MAX] = { - [CTA_STATUS-1] = sizeof(u_int32_t), - [CTA_TIMEOUT-1] = sizeof(u_int32_t), - [CTA_MARK-1] = sizeof(u_int32_t), - [CTA_USE-1] = sizeof(u_int32_t), - [CTA_ID-1] = sizeof(u_int32_t) + [CTA_STATUS-1] = sizeof(__be32), + [CTA_TIMEOUT-1] = sizeof(__be32), + [CTA_MARK-1] = sizeof(__be32), + [CTA_USE-1] = sizeof(__be32), + [CTA_ID-1] = sizeof(__be32) }; static int @@ -722,7 +722,7 @@ ctnetlink_del_conntrack(struct sock *ctn ct = tuplehash_to_ctrack(h); if (cda[CTA_ID-1]) { - u_int32_t id = ntohl(*(u_int32_t *)NFA_DATA(cda[CTA_ID-1])); + u_int32_t id = ntohl(*(__be32 *)NFA_DATA(cda[CTA_ID-1])); if (ct->id != id) { ip_conntrack_put(ct); return -ENOENT; @@ -832,7 +832,7 @@ static inline int ctnetlink_change_status(struct ip_conntrack *ct, struct nfattr *cda[]) { unsigned long d; - unsigned status = ntohl(*(u_int32_t *)NFA_DATA(cda[CTA_STATUS-1])); + unsigned status = ntohl(*(__be32 *)NFA_DATA(cda[CTA_STATUS-1])); d = ct->status ^ status; if (d & (IPS_EXPECTED|IPS_CONFIRMED|IPS_DYING)) @@ -936,7 +936,7 @@ ctnetlink_change_helper(struct ip_conntr static inline int ctnetlink_change_timeout(struct ip_conntrack *ct, struct nfattr *cda[]) { - u_int32_t timeout = ntohl(*(u_int32_t *)NFA_DATA(cda[CTA_TIMEOUT-1])); + u_int32_t timeout = ntohl(*(__be32 *)NFA_DATA(cda[CTA_TIMEOUT-1])); if (!del_timer(&ct->timeout)) return -ETIME; @@ -999,7 +999,7 @@ ctnetlink_change_conntrack(struct ip_con #if defined(CONFIG_IP_NF_CONNTRACK_MARK) if (cda[CTA_MARK-1]) - ct->mark = ntohl(*(u_int32_t *)NFA_DATA(cda[CTA_MARK-1])); + ct->mark = ntohl(*(__be32 *)NFA_DATA(cda[CTA_MARK-1])); #endif DEBUGP("all done\n"); @@ -1022,7 +1022,7 @@ ctnetlink_create_conntrack(struct nfattr if (!cda[CTA_TIMEOUT-1]) goto err; - ct->timeout.expires = ntohl(*(u_int32_t *)NFA_DATA(cda[CTA_TIMEOUT-1])); + ct->timeout.expires = ntohl(*(__be32 *)NFA_DATA(cda[CTA_TIMEOUT-1])); ct->timeout.expires = jiffies + ct->timeout.expires * HZ; ct->status |= IPS_CONFIRMED; @@ -1047,7 +1047,7 @@ ctnetlink_create_conntrack(struct nfattr #if defined(CONFIG_IP_NF_CONNTRACK_MARK) if (cda[CTA_MARK-1]) - ct->mark = ntohl(*(u_int32_t *)NFA_DATA(cda[CTA_MARK-1])); + ct->mark = ntohl(*(__be32 *)NFA_DATA(cda[CTA_MARK-1])); #endif DEBUGP("conntrack with id %u inserted\n", ct->id); @@ -1144,8 +1144,8 @@ ctnetlink_exp_dump_expect(struct sk_buff const struct ip_conntrack_expect *exp) { struct ip_conntrack *master = exp->master; - u_int32_t timeout = htonl((exp->timeout.expires - jiffies) / HZ); - u_int32_t id = htonl(exp->id); + __be32 timeout = htonl((exp->timeout.expires - jiffies) / HZ); + __be32 id = htonl(exp->id); if (ctnetlink_exp_dump_tuple(skb, &exp->tuple, CTA_EXPECT_TUPLE) < 0) goto nfattr_failure; @@ -1156,8 +1156,8 @@ ctnetlink_exp_dump_expect(struct sk_buff CTA_EXPECT_MASTER) < 0) goto nfattr_failure; - NFA_PUT(skb, CTA_EXPECT_TIMEOUT, sizeof(timeout), &timeout); - NFA_PUT(skb, CTA_EXPECT_ID, sizeof(u_int32_t), &id); + NFA_PUT(skb, CTA_EXPECT_TIMEOUT, sizeof(__be32), &timeout); + NFA_PUT(skb, CTA_EXPECT_ID, sizeof(__be32), &id); return 0; @@ -1277,8 +1277,8 @@ out: } static const size_t cta_min_exp[CTA_EXPECT_MAX] = { - [CTA_EXPECT_TIMEOUT-1] = sizeof(u_int32_t), - [CTA_EXPECT_ID-1] = sizeof(u_int32_t) + [CTA_EXPECT_TIMEOUT-1] = sizeof(__be32), + [CTA_EXPECT_ID-1] = sizeof(__be32) }; static int @@ -1326,7 +1326,7 @@ ctnetlink_get_expect(struct sock *ctnl, return -ENOENT; if (cda[CTA_EXPECT_ID-1]) { - u_int32_t id = *(u_int32_t *)NFA_DATA(cda[CTA_EXPECT_ID-1]); + __be32 id = *(__be32 *)NFA_DATA(cda[CTA_EXPECT_ID-1]); if (exp->id != ntohl(id)) { ip_conntrack_expect_put(exp); return -ENOENT; @@ -1380,8 +1380,8 @@ ctnetlink_del_expect(struct sock *ctnl, return -ENOENT; if (cda[CTA_EXPECT_ID-1]) { - u_int32_t id = - *(u_int32_t *)NFA_DATA(cda[CTA_EXPECT_ID-1]); + __be32 id = + *(__be32 *)NFA_DATA(cda[CTA_EXPECT_ID-1]); if (exp->id != ntohl(id)) { ip_conntrack_expect_put(exp); return -ENOENT; diff --git a/net/ipv4/netfilter/ip_conntrack_proto_sctp.c b/net/ipv4/netfilter/ip_conntrack_proto_sctp.c index 977fb59..1ccdd6e 100644 --- a/net/ipv4/netfilter/ip_conntrack_proto_sctp.c +++ b/net/ipv4/netfilter/ip_conntrack_proto_sctp.c @@ -209,7 +209,7 @@ static int sctp_print_conntrack(struct s for (offset = skb->nh.iph->ihl * 4 + sizeof(sctp_sctphdr_t), count = 0; \ offset < skb->len && \ (sch = skb_header_pointer(skb, offset, sizeof(_sch), &_sch)); \ - offset += (htons(sch->length) + 3) & ~3, count++) + offset += (ntohs(sch->length) + 3) & ~3, count++) /* Some validity checks to make sure the chunks are fine */ static 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 e7fa29e..bc895c7 100644 --- a/net/ipv4/netfilter/ip_conntrack_proto_tcp.c +++ b/net/ipv4/netfilter/ip_conntrack_proto_tcp.c @@ -521,8 +521,8 @@ static void tcp_sack(const struct sk_buf /* Fast path for timestamp-only option */ if (length == TCPOLEN_TSTAMP_ALIGNED*4 - && *(__u32 *)ptr == - __constant_ntohl((TCPOPT_NOP << 24) + && *(__be32 *)ptr == + __constant_htonl((TCPOPT_NOP << 24) | (TCPOPT_NOP << 16) | (TCPOPT_TIMESTAMP << 8) | TCPOLEN_TIMESTAMP)) @@ -553,7 +553,7 @@ static void tcp_sack(const struct sk_buf for (i = 0; i < (opsize - TCPOLEN_SACK_BASE); i += TCPOLEN_SACK_PERBLOCK) { - tmp = ntohl(*((u_int32_t *)(ptr+i)+1)); + tmp = ntohl(*((__be32 *)(ptr+i)+1)); if (after(tmp, *sack)) *sack = tmp; diff --git a/net/ipv4/netfilter/ip_nat_core.c b/net/ipv4/netfilter/ip_nat_core.c index c1a6146..d6ebc56 100644 --- a/net/ipv4/netfilter/ip_nat_core.c +++ b/net/ipv4/netfilter/ip_nat_core.c @@ -206,7 +206,7 @@ find_best_ips_proto(struct ip_conntrack_ const struct ip_conntrack *conntrack, enum ip_nat_manip_type maniptype) { - u_int32_t *var_ipp; + __be32 *var_ipp; /* Host order */ u_int32_t minip, maxip, j; @@ -550,9 +550,9 @@ int ip_nat_port_range_to_nfattr(struct sk_buff *skb, const struct ip_nat_range *range) { - NFA_PUT(skb, CTA_PROTONAT_PORT_MIN, sizeof(u_int16_t), + NFA_PUT(skb, CTA_PROTONAT_PORT_MIN, sizeof(__be16), &range->min.tcp.port); - NFA_PUT(skb, CTA_PROTONAT_PORT_MAX, sizeof(u_int16_t), + NFA_PUT(skb, CTA_PROTONAT_PORT_MAX, sizeof(__be16), &range->max.tcp.port); return 0; @@ -571,7 +571,7 @@ ip_nat_port_nfattr_to_range(struct nfatt if (tb[CTA_PROTONAT_PORT_MIN-1]) { ret = 1; range->min.tcp.port = - *(u_int16_t *)NFA_DATA(tb[CTA_PROTONAT_PORT_MIN-1]); + *(__be16 *)NFA_DATA(tb[CTA_PROTONAT_PORT_MIN-1]); } if (!tb[CTA_PROTONAT_PORT_MAX-1]) { @@ -580,7 +580,7 @@ ip_nat_port_nfattr_to_range(struct nfatt } else { ret = 1; range->max.tcp.port = - *(u_int16_t *)NFA_DATA(tb[CTA_PROTONAT_PORT_MAX-1]); + *(__be16 *)NFA_DATA(tb[CTA_PROTONAT_PORT_MAX-1]); } return ret; diff --git a/net/ipv4/netfilter/ip_nat_ftp.c b/net/ipv4/netfilter/ip_nat_ftp.c index d83757a..ca1aadc 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"); static int mangle_rfc959_packet(struct sk_buff **pskb, - u_int32_t newip, + __be32 newip, u_int16_t port, unsigned int matchoff, unsigned int matchlen, @@ -57,7 +57,7 @@ mangle_rfc959_packet(struct sk_buff **ps /* |1|132.235.1.2|6275| */ static int mangle_eprt_packet(struct sk_buff **pskb, - u_int32_t newip, + __be32 newip, u_int16_t port, unsigned int matchoff, unsigned int matchlen, @@ -79,7 +79,7 @@ mangle_eprt_packet(struct sk_buff **pskb /* |1|132.235.1.2|6275| */ static int mangle_epsv_packet(struct sk_buff **pskb, - u_int32_t newip, + __be32 newip, u_int16_t port, unsigned int matchoff, unsigned int matchlen, @@ -98,7 +98,7 @@ mangle_epsv_packet(struct sk_buff **pskb matchlen, buffer, strlen(buffer)); } -static int (*mangle[])(struct sk_buff **, u_int32_t, u_int16_t, +static int (*mangle[])(struct sk_buff **, __be32, u_int16_t, unsigned int, unsigned int, struct ip_conntrack *, @@ -120,7 +120,7 @@ static unsigned int ip_nat_ftp(struct sk struct ip_conntrack_expect *exp, u32 *seq) { - u_int32_t newip; + __be32 newip; u_int16_t port; int dir = CTINFO2DIR(ctinfo); struct ip_conntrack *ct = exp->master; diff --git a/net/ipv4/netfilter/ip_nat_helper_pptp.c b/net/ipv4/netfilter/ip_nat_helper_pptp.c index e546203..223e68a 100644 --- a/net/ipv4/netfilter/ip_nat_helper_pptp.c +++ b/net/ipv4/netfilter/ip_nat_helper_pptp.c @@ -149,7 +149,8 @@ pptp_outbound_pkt(struct sk_buff **pskb, struct ip_ct_pptp_master *ct_pptp_info = &ct->help.ct_pptp_info; struct ip_nat_pptp *nat_pptp_info = &ct->nat.help.nat_pptp_info; - u_int16_t msg, *cid = NULL, new_callid; + __u16 msg; + __be16 *cid = NULL, new_callid; new_callid = htons(ct_pptp_info->pns_call_id); @@ -299,7 +300,8 @@ pptp_inbound_pkt(struct sk_buff **pskb, union pptp_ctrl_union *pptpReq) { struct ip_nat_pptp *nat_pptp_info = &ct->nat.help.nat_pptp_info; - u_int16_t msg, new_cid = 0, new_pcid, *pcid = NULL, *cid = NULL; + u_int16_t msg; + __be16 new_cid = 0, new_pcid, *pcid = NULL, *cid = NULL; int ret = NF_ACCEPT, rv; diff --git a/net/ipv4/netfilter/ip_nat_proto_gre.c b/net/ipv4/netfilter/ip_nat_proto_gre.c index f7cad7c..c911184 100644 --- a/net/ipv4/netfilter/ip_nat_proto_gre.c +++ b/net/ipv4/netfilter/ip_nat_proto_gre.c @@ -49,7 +49,7 @@ gre_in_range(const struct ip_conntrack_t const union ip_conntrack_manip_proto *min, const union ip_conntrack_manip_proto *max) { - u_int32_t key; + __be32 key; if (maniptype == IP_NAT_MANIP_SRC) key = tuple->src.u.gre.key; @@ -68,7 +68,7 @@ gre_unique_tuple(struct ip_conntrack_tup const struct ip_conntrack *conntrack) { static u_int16_t key; - u_int16_t *keyptr; + __be16 *keyptr; unsigned int min, i, range_size; if (maniptype == IP_NAT_MANIP_SRC) diff --git a/net/ipv4/netfilter/ip_nat_proto_tcp.c b/net/ipv4/netfilter/ip_nat_proto_tcp.c index 1d381bf..dea05b0 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_t const union ip_conntrack_manip_proto *min, const union ip_conntrack_manip_proto *max) { - u_int16_t port; + __be16 port; if (maniptype == IP_NAT_MANIP_SRC) port = tuple->src.u.tcp.port; @@ -42,7 +42,7 @@ tcp_unique_tuple(struct ip_conntrack_tup const struct ip_conntrack *conntrack) { static u_int16_t port; - u_int16_t *portptr; + __be16 *portptr; unsigned int range_size, min, i; if (maniptype == IP_NAT_MANIP_SRC) @@ -93,8 +93,8 @@ tcp_manip_pkt(struct sk_buff **pskb, struct iphdr *iph = (struct iphdr *)((*pskb)->data + iphdroff); struct tcphdr *hdr; unsigned int hdroff = iphdroff + iph->ihl*4; - u32 oldip, newip; - u16 *portptr, newport, oldport; + __be32 oldip, newip; + __be16 *portptr, newport, oldport; int hdrsize = 8; /* TCP connection tracking guarantees this much */ /* this could be a inner header returned in icmp packet; in such @@ -130,7 +130,7 @@ tcp_manip_pkt(struct sk_buff **pskb, return 1; hdr->check = ip_nat_cheat_check(~oldip, newip, - ip_nat_cheat_check(oldport ^ 0xFFFF, + ip_nat_cheat_check(oldport ^ htons(0xFFFF), newport, hdr->check)); return 1; @@ -158,7 +158,7 @@ tcp_print(char *buffer, static unsigned int tcp_print_range(char *buffer, const struct ip_nat_range *range) { - if (range->min.tcp.port != 0 || range->max.tcp.port != 0xFFFF) { + if (range->min.tcp.port != 0 || range->max.tcp.port != htons(0xFFFF)) { if (range->min.tcp.port == range->max.tcp.port) return sprintf(buffer, "port %u ", ntohs(range->min.tcp.port)); diff --git a/net/ipv4/netfilter/ip_nat_rule.c b/net/ipv4/netfilter/ip_nat_rule.c index cb66b8b..32a1c49 100644 --- a/net/ipv4/netfilter/ip_nat_rule.c +++ b/net/ipv4/netfilter/ip_nat_rule.c @@ -122,7 +122,7 @@ static unsigned int ipt_snat_target(stru } /* Before 2.6.11 we did implicit source NAT if required. Warn about change. */ -static void warn_if_extra_mangle(u32 dstip, u32 srcip) +static void warn_if_extra_mangle(__be32 dstip, __be32 srcip) { static int warned = 0; struct flowi fl = { .nl_u = { .ip4_u = { .daddr = dstip } } }; @@ -243,7 +243,7 @@ alloc_null_binding(struct ip_conntrack * per-proto parts (hence not IP_NAT_RANGE_PROTO_SPECIFIED). Use reply in case it's already been mangled (eg local packet). */ - u_int32_t ip + __be32 ip = (HOOK2MANIP(hooknum) == IP_NAT_MANIP_SRC ? conntrack->tuplehash[IP_CT_DIR_REPLY].tuple.dst.ip : conntrack->tuplehash[IP_CT_DIR_REPLY].tuple.src.ip); @@ -260,7 +260,7 @@ alloc_null_binding_confirmed(struct ip_c struct ip_nat_info *info, unsigned int hooknum) { - u_int32_t ip + __be32 ip = (HOOK2MANIP(hooknum) == IP_NAT_MANIP_SRC ? conntrack->tuplehash[IP_CT_DIR_REPLY].tuple.dst.ip : conntrack->tuplehash[IP_CT_DIR_REPLY].tuple.src.ip); diff --git a/net/ipv4/netfilter/ip_nat_standalone.c b/net/ipv4/netfilter/ip_nat_standalone.c index 30cd4e1..601cd2b 100644 --- a/net/ipv4/netfilter/ip_nat_standalone.c +++ b/net/ipv4/netfilter/ip_nat_standalone.c @@ -162,7 +162,7 @@ ip_nat_in(unsigned int hooknum, const struct net_device *out, int (*okfn)(struct sk_buff *)) { - u_int32_t saddr, daddr; + __be32 saddr, daddr; unsigned int ret; saddr = (*pskb)->nh.iph->saddr; @@ -217,7 +217,7 @@ ip_nat_local_fn(unsigned int hooknum, const struct net_device *out, int (*okfn)(struct sk_buff *)) { - u_int32_t saddr, daddr; + __be32 saddr, daddr; unsigned int ret; /* root is playing with raw sockets. */ diff --git a/net/ipv4/netfilter/ipt_CLUSTERIP.c b/net/ipv4/netfilter/ipt_CLUSTERIP.c index 45c52d8..8f39852 100644 --- a/net/ipv4/netfilter/ipt_CLUSTERIP.c +++ b/net/ipv4/netfilter/ipt_CLUSTERIP.c @@ -53,7 +53,7 @@ struct clusterip_config { atomic_t entries; /* number of entries/rules * referencing us */ - u_int32_t clusterip; /* the IP address */ + __be32 clusterip; /* the IP address */ u_int8_t clustermac[ETH_ALEN]; /* the MAC address */ struct net_device *dev; /* device */ u_int16_t num_total_nodes; /* total number of nodes */ @@ -120,7 +120,7 @@ clusterip_config_entry_put(struct cluste } static struct clusterip_config * -__clusterip_config_find(u_int32_t clusterip) +__clusterip_config_find(__be32 clusterip) { struct list_head *pos; @@ -137,7 +137,7 @@ __clusterip_config_find(u_int32_t cluste } static inline struct clusterip_config * -clusterip_config_find_get(u_int32_t clusterip, int entry) +clusterip_config_find_get(__be32 clusterip, int entry) { struct clusterip_config *c; @@ -167,7 +167,7 @@ clusterip_config_init_nodelist(struct cl } static struct clusterip_config * -clusterip_config_init(struct ipt_clusterip_tgt_info *i, u_int32_t ip, +clusterip_config_init(struct ipt_clusterip_tgt_info *i, __be32 ip, struct net_device *dev) { struct clusterip_config *c; @@ -403,7 +403,7 @@ checkentry(const char *tablename, return 0; } - if (e->ip.dmsk.s_addr != 0xffffffff + if (e->ip.dmsk.s_addr != htonl(0xffffffff) || e->ip.dst.s_addr == 0) { printk(KERN_ERR "CLUSTERIP: Please specify destination IP\n"); return 0; diff --git a/net/ipv4/netfilter/ipt_DSCP.c b/net/ipv4/netfilter/ipt_DSCP.c index 6e31957..389e77f 100644 --- a/net/ipv4/netfilter/ipt_DSCP.c +++ b/net/ipv4/netfilter/ipt_DSCP.c @@ -37,12 +37,12 @@ target(struct sk_buff **pskb, if (((*pskb)->nh.iph->tos & IPT_DSCP_MASK) != sh_dscp) { - u_int16_t diffs[2]; + __be16 diffs[2]; if (!skb_make_writable(pskb, sizeof(struct iphdr))) return NF_DROP; - diffs[0] = htons((*pskb)->nh.iph->tos) ^ 0xFFFF; + diffs[0] = htons((*pskb)->nh.iph->tos) ^ htons(0xFFFF); (*pskb)->nh.iph->tos = ((*pskb)->nh.iph->tos & ~IPT_DSCP_MASK) | sh_dscp; diffs[1] = htons((*pskb)->nh.iph->tos); @@ -50,7 +50,7 @@ target(struct sk_buff **pskb, = csum_fold(csum_partial((char *)diffs, sizeof(diffs), (*pskb)->nh.iph->check - ^ 0xFFFF)); + ^ htons(0xFFFF))); } return IPT_CONTINUE; } diff --git a/net/ipv4/netfilter/ipt_ECN.c b/net/ipv4/netfilter/ipt_ECN.c index a131969..dd61099 100644 --- a/net/ipv4/netfilter/ipt_ECN.c +++ b/net/ipv4/netfilter/ipt_ECN.c @@ -29,12 +29,12 @@ set_ect_ip(struct sk_buff **pskb, const { if (((*pskb)->nh.iph->tos & IPT_ECN_IP_MASK) != (einfo->ip_ect & IPT_ECN_IP_MASK)) { - u_int16_t diffs[2]; + __be16 diffs[2]; if (!skb_make_writable(pskb, sizeof(struct iphdr))) return 0; - diffs[0] = htons((*pskb)->nh.iph->tos) ^ 0xFFFF; + diffs[0] = htons((*pskb)->nh.iph->tos) ^ htons(0xFFFF); (*pskb)->nh.iph->tos &= ~IPT_ECN_IP_MASK; (*pskb)->nh.iph->tos |= (einfo->ip_ect & IPT_ECN_IP_MASK); diffs[1] = htons((*pskb)->nh.iph->tos); @@ -42,7 +42,7 @@ set_ect_ip(struct sk_buff **pskb, const = csum_fold(csum_partial((char *)diffs, sizeof(diffs), (*pskb)->nh.iph->check - ^0xFFFF)); + ^htons(0xFFFF))); } return 1; } @@ -52,7 +52,7 @@ static inline int set_ect_tcp(struct sk_buff **pskb, const struct ipt_ECN_info *einfo, int inward) { struct tcphdr _tcph, *tcph; - u_int16_t diffs[2]; + __be16 diffs[2]; /* Not enought header? */ tcph = skb_header_pointer(*pskb, (*pskb)->nh.iph->ihl*4, @@ -80,12 +80,12 @@ set_ect_tcp(struct sk_buff **pskb, const if (einfo->operation & IPT_ECN_OP_SET_CWR) tcph->cwr = einfo->proto.tcp.cwr; diffs[1] = ((u_int16_t *)tcph)[6]; - diffs[0] = diffs[0] ^ 0xFFFF; + diffs[0] = diffs[0] ^ htons(0xFFFF); if ((*pskb)->ip_summed != CHECKSUM_UNNECESSARY) tcph->check = csum_fold(csum_partial((char *)diffs, sizeof(diffs), - tcph->check^0xFFFF)); + tcph->check^htons(0xFFFF))); return 1; } diff --git a/net/ipv4/netfilter/ipt_NETMAP.c b/net/ipv4/netfilter/ipt_NETMAP.c index e6e7b60..6643473 100644 --- a/net/ipv4/netfilter/ipt_NETMAP.c +++ b/net/ipv4/netfilter/ipt_NETMAP.c @@ -72,7 +72,7 @@ target(struct sk_buff **pskb, { struct ip_conntrack *ct; enum ip_conntrack_info ctinfo; - u_int32_t new_ip, netmask; + __be32 new_ip, netmask; const struct ip_nat_multi_range_compat *mr = targinfo; struct ip_nat_range newrange; diff --git a/net/ipv4/netfilter/ipt_REDIRECT.c b/net/ipv4/netfilter/ipt_REDIRECT.c index 5245bfd..e3956fd 100644 --- a/net/ipv4/netfilter/ipt_REDIRECT.c +++ b/net/ipv4/netfilter/ipt_REDIRECT.c @@ -73,7 +73,7 @@ redirect_target(struct sk_buff **pskb, { struct ip_conntrack *ct; enum ip_conntrack_info ctinfo; - u_int32_t newdst; + __be32 newdst; const struct ip_nat_multi_range_compat *mr = targinfo; struct ip_nat_range newrange; diff --git a/net/ipv4/netfilter/ipt_REJECT.c b/net/ipv4/netfilter/ipt_REJECT.c index f057025..9f25259 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 *o struct iphdr *iph = oldskb->nh.iph; struct tcphdr _otcph, *oth, *tcph; struct rtable *rt; - u_int16_t tmp_port; - u_int32_t tmp_addr; + __be16 tmp_port; + __be32 tmp_addr; unsigned int tcplen; int needs_ack; int hh_len; diff --git a/net/ipv4/netfilter/ipt_SAME.c b/net/ipv4/netfilter/ipt_SAME.c index 7a0536d..d14df8b 100644 --- a/net/ipv4/netfilter/ipt_SAME.c +++ b/net/ipv4/netfilter/ipt_SAME.c @@ -148,7 +148,8 @@ same_target(struct sk_buff **pskb, { struct ip_conntrack *ct; enum ip_conntrack_info ctinfo; - u_int32_t tmpip, aindex, new_ip; + u_int32_t tmpip, aindex; + __be32 new_ip; const struct ipt_same_info *same = targinfo; struct ip_nat_range newrange; const struct ip_conntrack_tuple *t; diff --git a/net/ipv4/netfilter/ipt_TCPMSS.c b/net/ipv4/netfilter/ipt_TCPMSS.c index 8db70d6..aa6f2ba 100644 --- a/net/ipv4/netfilter/ipt_TCPMSS.c +++ b/net/ipv4/netfilter/ipt_TCPMSS.c @@ -54,7 +54,8 @@ ipt_tcpmss_target(struct sk_buff **pskb, const struct ipt_tcpmss_info *tcpmssinfo = targinfo; struct tcphdr *tcph; struct iphdr *iph; - u_int16_t tcplen, newtotlen, oldval, newmss; + u_int16_t tcplen, newmss; + __be16 newtotlen, oldval; unsigned int i; u_int8_t *opt; @@ -118,7 +119,7 @@ ipt_tcpmss_target(struct sk_buff **pskb, opt[i+2] = (newmss & 0xff00) >> 8; opt[i+3] = (newmss & 0x00ff); - tcph->check = cheat_check(htons(oldmss)^0xFFFF, + tcph->check = cheat_check(htons(oldmss)^htons(0xFFFF), htons(newmss), tcph->check); @@ -160,7 +161,7 @@ ipt_tcpmss_target(struct sk_buff **pskb, opt = (u_int8_t *)tcph + sizeof(struct tcphdr); memmove(opt + TCPOLEN_MSS, opt, tcplen - sizeof(struct tcphdr)); - tcph->check = cheat_check(htons(tcplen) ^ 0xFFFF, + tcph->check = cheat_check(htons(tcplen) ^ htons(0xFFFF), htons(tcplen + TCPOLEN_MSS), tcph->check); tcplen += TCPOLEN_MSS; @@ -171,13 +172,13 @@ ipt_tcpmss_target(struct sk_buff **pskb, tcph->check = cheat_check(~0, *((u_int32_t *)opt), tcph->check); - oldval = ((u_int16_t *)tcph)[6]; + oldval = ((__be16 *)tcph)[6]; tcph->doff += TCPOLEN_MSS/4; - tcph->check = cheat_check(oldval ^ 0xFFFF, - ((u_int16_t *)tcph)[6], tcph->check); + tcph->check = cheat_check(oldval ^ htons(0xFFFF), + ((__be16 *)tcph)[6], tcph->check); newtotlen = htons(ntohs(iph->tot_len) + TCPOLEN_MSS); - iph->check = cheat_check(iph->tot_len ^ 0xFFFF, + iph->check = cheat_check(iph->tot_len ^ htons(0xFFFF), newtotlen, iph->check); iph->tot_len = newtotlen; diff --git a/net/ipv4/netfilter/ipt_TOS.c b/net/ipv4/netfilter/ipt_TOS.c index deadb36..7093941 100644 --- a/net/ipv4/netfilter/ipt_TOS.c +++ b/net/ipv4/netfilter/ipt_TOS.c @@ -31,12 +31,12 @@ target(struct sk_buff **pskb, const struct ipt_tos_target_info *tosinfo = targinfo; if (((*pskb)->nh.iph->tos & IPTOS_TOS_MASK) != tosinfo->tos) { - u_int16_t diffs[2]; + __be16 diffs[2]; if (!skb_make_writable(pskb, sizeof(struct iphdr))) return NF_DROP; - diffs[0] = htons((*pskb)->nh.iph->tos) ^ 0xFFFF; + diffs[0] = htons((*pskb)->nh.iph->tos) ^ htons(0xFFFF); (*pskb)->nh.iph->tos = ((*pskb)->nh.iph->tos & IPTOS_PREC_MASK) | tosinfo->tos; @@ -45,7 +45,7 @@ target(struct sk_buff **pskb, = csum_fold(csum_partial((char *)diffs, sizeof(diffs), (*pskb)->nh.iph->check - ^0xFFFF)); + ^htons(0xFFFF))); } return IPT_CONTINUE; } diff --git a/net/ipv4/netfilter/ipt_TTL.c b/net/ipv4/netfilter/ipt_TTL.c index b9ae6a9..4d0904d 100644 --- a/net/ipv4/netfilter/ipt_TTL.c +++ b/net/ipv4/netfilter/ipt_TTL.c @@ -54,12 +54,12 @@ ipt_ttl_target(struct sk_buff **pskb, co } if (new_ttl != iph->ttl) { - diffs[0] = htons(((unsigned)iph->ttl) << 8) ^ 0xFFFF; + diffs[0] = htons(((unsigned)iph->ttl) << 8) ^ htons(0xFFFF); iph->ttl = new_ttl; diffs[1] = htons(((unsigned)iph->ttl) << 8); iph->check = csum_fold(csum_partial((char *)diffs, sizeof(diffs), - iph->check^0xFFFF)); + iph->check^htons(0xFFFF))); } return IPT_CONTINUE; diff --git a/net/ipv4/netfilter/ipt_hashlimit.c b/net/ipv4/netfilter/ipt_hashlimit.c index 2dd1ccc..4283f7d 100644 --- a/net/ipv4/netfilter/ipt_hashlimit.c +++ b/net/ipv4/netfilter/ipt_hashlimit.c @@ -52,11 +52,11 @@ static struct file_operations dl_file_op /* hash table crap */ struct dsthash_dst { - u_int32_t src_ip; - u_int32_t dst_ip; + __be32 src_ip; + __be32 dst_ip; /* ports have to be consecutive !!! */ - u_int16_t src_port; - u_int16_t dst_port; + __be16 src_port; + __be16 dst_port; }; struct dsthash_ent { @@ -107,8 +107,10 @@ static inline int dst_cmp(const struct d static inline u_int32_t hash_dst(const struct ipt_hashlimit_htable *ht, const struct dsthash_dst *dst) { - return (jhash_3words(dst->dst_ip, (dst->dst_port<<16 | dst->src_port), - dst->src_ip, ht->rnd) % ht->cfg.size); + return (jhash_3words((__force u32)dst->dst_ip, + ((__force u32)dst->dst_port<<16 | + (__force u32)dst->src_port), + (__force u32)dst->src_ip, ht->rnd) % ht->cfg.size); } static inline struct dsthash_ent * @@ -381,7 +383,7 @@ static inline void rateinfo_recalc(struc } static inline int get_ports(const struct sk_buff *skb, int offset, - u16 ports[2]) + __be16 ports[2]) { union { struct tcphdr th; @@ -446,7 +448,7 @@ hashlimit_match(const struct sk_buff *sk dst.src_ip = skb->nh.iph->saddr; if (hinfo->cfg.mode & IPT_HASHLIMIT_HASH_DPT ||hinfo->cfg.mode & IPT_HASHLIMIT_HASH_SPT) { - u_int16_t ports[2]; + __be16 ports[2]; if (get_ports(skb, offset, ports)) { /* We've been asked to examine this packet, and we can't. Hence, no choice but to drop. */ diff --git a/net/ipv4/netfilter/ipt_multiport.c b/net/ipv4/netfilter/ipt_multiport.c index 99e8188..4c7e461 100644 --- a/net/ipv4/netfilter/ipt_multiport.c +++ b/net/ipv4/netfilter/ipt_multiport.c @@ -99,7 +99,7 @@ match(const struct sk_buff *skb, int offset, int *hotdrop) { - u16 _ports[2], *pptr; + __be16 _ports[2], *pptr; const struct ipt_multiport *multiinfo = matchinfo; if (offset) @@ -130,7 +130,7 @@ match_v1(const struct sk_buff *skb, int offset, int *hotdrop) { - u16 _ports[2], *pptr; + __be16 _ports[2], *pptr; const struct ipt_multiport_v1 *multiinfo = matchinfo; if (offset) diff --git a/net/ipv4/netfilter/ipt_recent.c b/net/ipv4/netfilter/ipt_recent.c index 261cbb4..2156d3d 100644 --- a/net/ipv4/netfilter/ipt_recent.c +++ b/net/ipv4/netfilter/ipt_recent.c @@ -53,7 +53,7 @@ MODULE_PARM_DESC(ip_list_perms,"permissi /* Structure of our list of recently seen addresses. */ struct recent_ip_list { - u_int32_t addr; + __be32 addr; u_int8_t ttl; unsigned long last_seen; unsigned long *last_pkts; @@ -107,10 +107,10 @@ match(const struct sk_buff *skb, int *hotdrop); /* Function to hash a given address into the hash table of table_size size */ -static int hash_func(unsigned int addr, int table_size) +static int hash_func(__be32 addr, int table_size) { int result = 0; - unsigned int value = addr; + unsigned int value = (__force unsigned int)addr; do { result ^= value; } while((value >>= HASH_LOG)); #ifdef DEBUG @@ -184,14 +184,14 @@ static int ip_recent_ctrl(struct file *f char c, *cp; union iaddr { uint8_t bytes[4]; - uint32_t word; + __be32 word; } res; uint8_t *pp = res.bytes; int digit; char buffer[20]; int len, check_set = 0, count; - u_int32_t addr = 0; + __be32 addr = 0; struct sk_buff *skb; struct ipt_recent_info *info; struct recent_ip_tables *curr_table; @@ -362,7 +362,8 @@ match(const struct sk_buff *skb, int pkt_count, hits_found, ans; unsigned long now; const struct ipt_recent_info *info = matchinfo; - u_int32_t addr = 0, time_temp; + __be32 addr = 0; + u_int32_t time_temp; u_int8_t ttl = skb->nh.iph->ttl; int *hash_table; int orig_hash_result, hash_result, temp, location = 0, time_loc, end_collision_chain = -1; @@ -404,7 +405,10 @@ match(const struct sk_buff *skb, spin_lock_bh(&curr_table->list_lock); r_list = curr_table->table; - if(info->side == IPT_RECENT_DEST) addr = skb->nh.iph->daddr; else addr = skb->nh.iph->saddr; + if (info->side == IPT_RECENT_DEST) + addr = skb->nh.iph->daddr; + else + addr = skb->nh.iph->saddr; if(!addr) { #ifdef DEBUG diff --git a/net/ipv4/netfilter/ipt_sctp.c b/net/ipv4/netfilter/ipt_sctp.c index fe2b327..a8994cb 100644 --- a/net/ipv4/netfilter/ipt_sctp.c +++ b/net/ipv4/netfilter/ipt_sctp.c @@ -64,7 +64,7 @@ match_packet(const struct sk_buff *skb, duprintf("Chunk num: %d\toffset: %d\ttype: %d\tlength: %d\tflags: %x\n", ++i, offset, sch->type, htons(sch->length), sch->flags); - offset += (htons(sch->length) + 3) & ~3; + offset += (ntohs(sch->length) + 3) & ~3; duprintf("skb->len: %d\toffset: %d\n", skb->len, offset); diff --git a/net/ipv4/netfilter/iptable_mangle.c b/net/ipv4/netfilter/iptable_mangle.c index 160eb11..e6d67f4 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, { unsigned int ret; u_int8_t tos; - u_int32_t saddr, daddr; + __be32 saddr, daddr; unsigned long nfmark; /* root is playing with raw sockets. */ -- 0.99.9.GIT