Skip to content

Commit

Permalink
[IPV4]: annotate struct in_ifaddr
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Al Viro authored and David S. Miller committed Sep 29, 2006
1 parent 6d85c10 commit a144ea4
Show file tree
Hide file tree
Showing 14 changed files with 27 additions and 27 deletions.
4 changes: 2 additions & 2 deletions arch/ia64/hp/sim/simeth.c
Original file line number Diff line number Diff line change
Expand Up @@ -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",
dev->name, htonl(ifa->ifa_local));
dev->name, ntohl(ifa->ifa_local));

/*
* XXX Fix me
Expand All @@ -331,7 +331,7 @@ simeth_device_event(struct notifier_block *this,unsigned long event, void *ptr)
local = dev->priv;
/* now do it for real */
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);

printk(KERN_INFO "simeth: netdev_attach/detach: event=%s ->%d\n",
Expand Down
2 changes: 1 addition & 1 deletion arch/um/drivers/net_kern.c
Original file line number Diff line number Diff line change
Expand Up @@ -825,7 +825,7 @@ int dev_netmask(void *d, void *m)
struct net_device *dev = d;
struct in_device *ip = dev->ip_ptr;
struct in_ifaddr *in;
__u32 *mask_out = m;
__be32 *mask_out = m;

if(ip == NULL)
return(1);
Expand Down
2 changes: 1 addition & 1 deletion arch/xtensa/platform-iss/network.c
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ static void dev_ip_addr(void *d, char *buf, char *bin_buf)
struct net_device *dev = d;
struct in_device *ip = dev->ip_ptr;
struct in_ifaddr *in;
u32 addr;
__be32 addr;

if ((ip == NULL) || ((in = ip->ifa_list) == NULL)) {
printk(KERN_WARNING "Device not assigned an IP address!\n");
Expand Down
4 changes: 2 additions & 2 deletions drivers/isdn/i4l/isdn_net.c
Original file line number Diff line number Diff line change
Expand Up @@ -1614,8 +1614,8 @@ isdn_net_ciscohdlck_slarp_send_reply(isdn_net_local *lp)
struct sk_buff *skb;
unsigned char *p;
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) {
/* take primary(first) address of interface */
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/bonding/bond_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -2252,7 +2252,7 @@ static u32 bond_glean_dev_ip(struct net_device *dev)
{
struct in_device *idev;
struct in_ifaddr *ifa;
u32 addr = 0;
__be32 addr = 0;

if (!dev)
return 0;
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/wan/hdlc_cisco.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ static int cisco_rx(struct sk_buff *skb)
struct hdlc_header *data = (struct hdlc_header*)skb->data;
struct cisco_packet *cisco_data;
struct in_device *in_dev;
u32 addr, mask;
__be32 addr, mask;

if (skb->len < sizeof(struct hdlc_header))
goto rx_error;
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/wan/syncppp.c
Original file line number Diff line number Diff line change
Expand Up @@ -763,7 +763,7 @@ static void sppp_cisco_input (struct sppp *sp, struct sk_buff *skb)
{
struct in_device *in_dev;
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
rcu_read_lock();
if ((in_dev = __in_dev_get_rcu(dev)) != NULL)
Expand Down
4 changes: 2 additions & 2 deletions drivers/net/wireless/strip.c
Original file line number Diff line number Diff line change
Expand Up @@ -1342,7 +1342,7 @@ static unsigned char *strip_make_packet(unsigned char *buffer,
* 'broadcast hub' radio (First byte of address being 0xFF means broadcast)
*/
if (haddr.c[0] == 0xFF) {
u32 brd = 0;
__be32 brd = 0;
struct in_device *in_dev;

rcu_read_lock();
Expand Down Expand Up @@ -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 doprobe = (long) jiffies - strip_info->watchdog_doprobe >= 0
&& !doreset;
u32 addr, brd;
__be32 addr, brd;

/*
* 1. If we have a packet, encapsulate it and put it in the buffer
Expand Down
10 changes: 5 additions & 5 deletions include/linux/inetdevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,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;
Expand Down
4 changes: 2 additions & 2 deletions net/ipv4/devinet.c
Original file line number Diff line number Diff line change
Expand Up @@ -805,7 +805,7 @@ int devinet_ioctl(unsigned int cmd, void __user *arg)
break;
ret = 0;
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);
ifa->ifa_mask = sin->sin_addr.s_addr;
ifa->ifa_prefixlen = inet_mask_len(ifa->ifa_mask);
Expand Down Expand Up @@ -931,7 +931,7 @@ static u32 confirm_addr_indev(struct in_device *in_dev, u32 dst,
u32 local, int scope)
{
int same = 0;
u32 addr = 0;
__be32 addr = 0;

for_ifa(in_dev) {
if (!addr &&
Expand Down
12 changes: 6 additions & 6 deletions net/ipv4/fib_frontend.c
Original file line number Diff line number Diff line change
Expand Up @@ -667,9 +667,9 @@ void fib_add_ifaddr(struct in_ifaddr *ifa)
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);
Expand All @@ -685,7 +685,7 @@ void fib_add_ifaddr(struct in_ifaddr *ifa)
return;

/* 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);

if (!ZERONET(prefix) && !(ifa->ifa_flags&IFA_F_SECONDARY) &&
Expand All @@ -707,8 +707,8 @@ static void fib_del_ifaddr(struct in_ifaddr *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
Expand Down
2 changes: 1 addition & 1 deletion net/ipv4/icmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -895,7 +895,7 @@ static void icmp_address_reply(struct sk_buff *skb)
if (in_dev->ifa_list &&
IN_DEV_LOG_MARTIANS(in_dev) &&
IN_DEV_FORWARD(in_dev)) {
u32 _mask, *mp;
__be32 _mask, *mp;

mp = skb_header_pointer(skb, 0, sizeof(_mask), &_mask);
BUG_ON(mp == NULL);
Expand Down
2 changes: 1 addition & 1 deletion net/ipv4/netfilter/ip_conntrack_netbios_ns.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,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)
Expand Down
2 changes: 1 addition & 1 deletion net/ipv4/netfilter/ipt_REDIRECT.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,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;

Expand Down

0 comments on commit a144ea4

Please sign in to comment.