Browse Source

[IPV4]: annotate struct in_ifaddr

ifa_local, ifa_address, ifa_mask, ifa_broadcast and ifa_anycast are
net-endian.  Annotated them and variables that are inferred to be
net-endian.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: David S. Miller <davem@davemloft.net>
Al Viro 18 years ago
parent
commit
a144ea4b7a

+ 2 - 2
arch/ia64/hp/sim/simeth.c

@@ -320,7 +320,7 @@ simeth_device_event(struct notifier_block *this,unsigned long event, void *ptr)
 	}
 	}
 
 
 	printk(KERN_INFO "simeth_device_event: %s ipaddr=0x%x\n",
 	printk(KERN_INFO "simeth_device_event: %s ipaddr=0x%x\n",
-	       dev->name, htonl(ifa->ifa_local));
+	       dev->name, ntohl(ifa->ifa_local));
 
 
 	/*
 	/*
 	 * XXX Fix me
 	 * XXX Fix me
@@ -331,7 +331,7 @@ simeth_device_event(struct notifier_block *this,unsigned long event, void *ptr)
 	local = dev->priv;
 	local = dev->priv;
 	/* now do it for real */
 	/* now do it for real */
 	r = event == NETDEV_UP ?
 	r = event == NETDEV_UP ?
-		netdev_attach(local->simfd, dev->irq, htonl(ifa->ifa_local)):
+		netdev_attach(local->simfd, dev->irq, ntohl(ifa->ifa_local)):
 		netdev_detach(local->simfd);
 		netdev_detach(local->simfd);
 
 
 	printk(KERN_INFO "simeth: netdev_attach/detach: event=%s ->%d\n",
 	printk(KERN_INFO "simeth: netdev_attach/detach: event=%s ->%d\n",

+ 1 - 1
arch/um/drivers/net_kern.c

@@ -825,7 +825,7 @@ int dev_netmask(void *d, void *m)
 	struct net_device *dev = d;
 	struct net_device *dev = d;
 	struct in_device *ip = dev->ip_ptr;
 	struct in_device *ip = dev->ip_ptr;
 	struct in_ifaddr *in;
 	struct in_ifaddr *in;
-	__u32 *mask_out = m;
+	__be32 *mask_out = m;
 
 
 	if(ip == NULL) 
 	if(ip == NULL) 
 		return(1);
 		return(1);

+ 1 - 1
arch/xtensa/platform-iss/network.c

@@ -201,7 +201,7 @@ static void dev_ip_addr(void *d, char *buf, char *bin_buf)
 	struct net_device *dev = d;
 	struct net_device *dev = d;
 	struct in_device *ip = dev->ip_ptr;
 	struct in_device *ip = dev->ip_ptr;
 	struct in_ifaddr *in;
 	struct in_ifaddr *in;
-	u32 addr;
+	__be32 addr;
 
 
 	if ((ip == NULL) || ((in = ip->ifa_list) == NULL)) {
 	if ((ip == NULL) || ((in = ip->ifa_list) == NULL)) {
 		printk(KERN_WARNING "Device not assigned an IP address!\n");
 		printk(KERN_WARNING "Device not assigned an IP address!\n");

+ 2 - 2
drivers/isdn/i4l/isdn_net.c

@@ -1614,8 +1614,8 @@ isdn_net_ciscohdlck_slarp_send_reply(isdn_net_local *lp)
 	struct sk_buff *skb;
 	struct sk_buff *skb;
 	unsigned char *p;
 	unsigned char *p;
 	struct in_device *in_dev = NULL;
 	struct in_device *in_dev = NULL;
-	u32 addr = 0;		/* local ipv4 address */
-	u32 mask = 0;		/* local netmask */
+	__be32 addr = 0;		/* local ipv4 address */
+	__be32 mask = 0;		/* local netmask */
 
 
 	if ((in_dev = lp->netdev->dev.ip_ptr) != NULL) {
 	if ((in_dev = lp->netdev->dev.ip_ptr) != NULL) {
 		/* take primary(first) address of interface */
 		/* take primary(first) address of interface */

+ 1 - 1
drivers/net/bonding/bond_main.c

@@ -2252,7 +2252,7 @@ static u32 bond_glean_dev_ip(struct net_device *dev)
 {
 {
 	struct in_device *idev;
 	struct in_device *idev;
 	struct in_ifaddr *ifa;
 	struct in_ifaddr *ifa;
-	u32 addr = 0;
+	__be32 addr = 0;
 
 
 	if (!dev)
 	if (!dev)
 		return 0;
 		return 0;

+ 1 - 1
drivers/net/wan/hdlc_cisco.c

@@ -161,7 +161,7 @@ static int cisco_rx(struct sk_buff *skb)
 	struct hdlc_header *data = (struct hdlc_header*)skb->data;
 	struct hdlc_header *data = (struct hdlc_header*)skb->data;
 	struct cisco_packet *cisco_data;
 	struct cisco_packet *cisco_data;
 	struct in_device *in_dev;
 	struct in_device *in_dev;
-	u32 addr, mask;
+	__be32 addr, mask;
 
 
 	if (skb->len < sizeof(struct hdlc_header))
 	if (skb->len < sizeof(struct hdlc_header))
 		goto rx_error;
 		goto rx_error;

+ 1 - 1
drivers/net/wan/syncppp.c

@@ -763,7 +763,7 @@ static void sppp_cisco_input (struct sppp *sp, struct sk_buff *skb)
 		{
 		{
 		struct in_device *in_dev;
 		struct in_device *in_dev;
 		struct in_ifaddr *ifa;
 		struct in_ifaddr *ifa;
-		u32 addr = 0, mask = ~0; /* FIXME: is the mask correct? */
+		__be32 addr = 0, mask = ~0; /* FIXME: is the mask correct? */
 #ifdef CONFIG_INET
 #ifdef CONFIG_INET
 		rcu_read_lock();
 		rcu_read_lock();
 		if ((in_dev = __in_dev_get_rcu(dev)) != NULL)
 		if ((in_dev = __in_dev_get_rcu(dev)) != NULL)

+ 2 - 2
drivers/net/wireless/strip.c

@@ -1342,7 +1342,7 @@ static unsigned char *strip_make_packet(unsigned char *buffer,
 	 * 'broadcast hub' radio (First byte of address being 0xFF means broadcast)
 	 * 'broadcast hub' radio (First byte of address being 0xFF means broadcast)
 	 */
 	 */
 	if (haddr.c[0] == 0xFF) {
 	if (haddr.c[0] == 0xFF) {
-		u32 brd = 0;
+		__be32 brd = 0;
 		struct in_device *in_dev;
 		struct in_device *in_dev;
 
 
 		rcu_read_lock();
 		rcu_read_lock();
@@ -1406,7 +1406,7 @@ static void strip_send(struct strip *strip_info, struct sk_buff *skb)
 	int doreset = (long) jiffies - strip_info->watchdog_doreset >= 0;
 	int doreset = (long) jiffies - strip_info->watchdog_doreset >= 0;
 	int doprobe = (long) jiffies - strip_info->watchdog_doprobe >= 0
 	int doprobe = (long) jiffies - strip_info->watchdog_doprobe >= 0
 	    && !doreset;
 	    && !doreset;
-	u32 addr, brd;
+	__be32 addr, brd;
 
 
 	/*
 	/*
 	 * 1. If we have a packet, encapsulate it and put it in the buffer
 	 * 1. If we have a packet, encapsulate it and put it in the buffer

+ 5 - 5
include/linux/inetdevice.h

@@ -90,11 +90,11 @@ struct in_ifaddr
 	struct in_ifaddr	*ifa_next;
 	struct in_ifaddr	*ifa_next;
 	struct in_device	*ifa_dev;
 	struct in_device	*ifa_dev;
 	struct rcu_head		rcu_head;
 	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_scope;
 	unsigned char		ifa_flags;
 	unsigned char		ifa_flags;
 	unsigned char		ifa_prefixlen;
 	unsigned char		ifa_prefixlen;

+ 2 - 2
net/ipv4/devinet.c

@@ -805,7 +805,7 @@ int devinet_ioctl(unsigned int cmd, void __user *arg)
 			break;
 			break;
 		ret = 0;
 		ret = 0;
 		if (ifa->ifa_mask != sin->sin_addr.s_addr) {
 		if (ifa->ifa_mask != sin->sin_addr.s_addr) {
-			u32 old_mask = ifa->ifa_mask;
+			__be32 old_mask = ifa->ifa_mask;
 			inet_del_ifa(in_dev, ifap, 0);
 			inet_del_ifa(in_dev, ifap, 0);
 			ifa->ifa_mask = sin->sin_addr.s_addr;
 			ifa->ifa_mask = sin->sin_addr.s_addr;
 			ifa->ifa_prefixlen = inet_mask_len(ifa->ifa_mask);
 			ifa->ifa_prefixlen = inet_mask_len(ifa->ifa_mask);
@@ -931,7 +931,7 @@ static u32 confirm_addr_indev(struct in_device *in_dev, u32 dst,
 			      u32 local, int scope)
 			      u32 local, int scope)
 {
 {
 	int same = 0;
 	int same = 0;
-	u32 addr = 0;
+	__be32 addr = 0;
 
 
 	for_ifa(in_dev) {
 	for_ifa(in_dev) {
 		if (!addr &&
 		if (!addr &&

+ 6 - 6
net/ipv4/fib_frontend.c

@@ -667,9 +667,9 @@ void fib_add_ifaddr(struct in_ifaddr *ifa)
 	struct in_device *in_dev = ifa->ifa_dev;
 	struct in_device *in_dev = ifa->ifa_dev;
 	struct net_device *dev = in_dev->dev;
 	struct net_device *dev = in_dev->dev;
 	struct in_ifaddr *prim = ifa;
 	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) {
 	if (ifa->ifa_flags&IFA_F_SECONDARY) {
 		prim = inet_ifa_byprefix(in_dev, prefix, mask);
 		prim = inet_ifa_byprefix(in_dev, prefix, mask);
@@ -685,7 +685,7 @@ void fib_add_ifaddr(struct in_ifaddr *ifa)
 		return;
 		return;
 
 
 	/* Add broadcast address, if it is explicitly assigned. */
 	/* Add broadcast address, if it is explicitly assigned. */
-	if (ifa->ifa_broadcast && ifa->ifa_broadcast != 0xFFFFFFFF)
+	if (ifa->ifa_broadcast && ifa->ifa_broadcast != htonl(0xFFFFFFFF))
 		fib_magic(RTM_NEWROUTE, RTN_BROADCAST, ifa->ifa_broadcast, 32, prim);
 		fib_magic(RTM_NEWROUTE, RTN_BROADCAST, ifa->ifa_broadcast, 32, prim);
 
 
 	if (!ZERONET(prefix) && !(ifa->ifa_flags&IFA_F_SECONDARY) &&
 	if (!ZERONET(prefix) && !(ifa->ifa_flags&IFA_F_SECONDARY) &&
@@ -707,8 +707,8 @@ static void fib_del_ifaddr(struct in_ifaddr *ifa)
 	struct net_device *dev = in_dev->dev;
 	struct net_device *dev = in_dev->dev;
 	struct in_ifaddr *ifa1;
 	struct in_ifaddr *ifa1;
 	struct in_ifaddr *prim = ifa;
 	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 LOCAL_OK	1
 #define BRD_OK		2
 #define BRD_OK		2
 #define BRD0_OK		4
 #define BRD0_OK		4

+ 1 - 1
net/ipv4/icmp.c

@@ -895,7 +895,7 @@ static void icmp_address_reply(struct sk_buff *skb)
 	if (in_dev->ifa_list &&
 	if (in_dev->ifa_list &&
 	    IN_DEV_LOG_MARTIANS(in_dev) &&
 	    IN_DEV_LOG_MARTIANS(in_dev) &&
 	    IN_DEV_FORWARD(in_dev)) {
 	    IN_DEV_FORWARD(in_dev)) {
-		u32 _mask, *mp;
+		__be32 _mask, *mp;
 
 
 		mp = skb_header_pointer(skb, 0, sizeof(_mask), &_mask);
 		mp = skb_header_pointer(skb, 0, sizeof(_mask), &_mask);
 		BUG_ON(mp == NULL);
 		BUG_ON(mp == NULL);

+ 1 - 1
net/ipv4/netfilter/ip_conntrack_netbios_ns.c

@@ -48,7 +48,7 @@ static int help(struct sk_buff **pskb,
 	struct iphdr *iph = (*pskb)->nh.iph;
 	struct iphdr *iph = (*pskb)->nh.iph;
 	struct rtable *rt = (struct rtable *)(*pskb)->dst;
 	struct rtable *rt = (struct rtable *)(*pskb)->dst;
 	struct in_device *in_dev;
 	struct in_device *in_dev;
-	u_int32_t mask = 0;
+	__be32 mask = 0;
 
 
 	/* we're only interested in locally generated packets */
 	/* we're only interested in locally generated packets */
 	if ((*pskb)->sk == NULL)
 	if ((*pskb)->sk == NULL)

+ 1 - 1
net/ipv4/netfilter/ipt_REDIRECT.c

@@ -61,7 +61,7 @@ redirect_target(struct sk_buff **pskb,
 {
 {
 	struct ip_conntrack *ct;
 	struct ip_conntrack *ct;
 	enum ip_conntrack_info ctinfo;
 	enum ip_conntrack_info ctinfo;
-	u_int32_t newdst;
+	__be32 newdst;
 	const struct ip_nat_multi_range_compat *mr = targinfo;
 	const struct ip_nat_multi_range_compat *mr = targinfo;
 	struct ip_nat_range newrange;
 	struct ip_nat_range newrange;