aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4
diff options
context:
space:
mode:
authorJoe Perches <joe@perches.com>2007-12-16 16:45:43 -0500
committerDavid S. Miller <davem@davemloft.net>2008-01-28 17:58:15 -0500
commitf97c1e0c6ebdb606c97b6cb5e837c6110ac5a961 (patch)
tree2af3da0114614a127099f9ab2ef706f676faa376 /net/ipv4
parent21cf2253ebcf070bc307e0b56d696a2519c75cb4 (diff)
[IPV4] net/ipv4: Use ipv4_is_<type>
Signed-off-by: Joe Perches <joe@perches.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4')
-rw-r--r--net/ipv4/arp.c2
-rw-r--r--net/ipv4/datagram.c2
-rw-r--r--net/ipv4/devinet.c4
-rw-r--r--net/ipv4/fib_frontend.c6
-rw-r--r--net/ipv4/igmp.c12
-rw-r--r--net/ipv4/ip_gre.c23
-rw-r--r--net/ipv4/ipmr.c6
-rw-r--r--net/ipv4/raw.c2
-rw-r--r--net/ipv4/route.c52
-rw-r--r--net/ipv4/udp.c2
10 files changed, 60 insertions, 51 deletions
diff --git a/net/ipv4/arp.c b/net/ipv4/arp.c
index 1102fb3d8018..fdf12d1c350e 100644
--- a/net/ipv4/arp.c
+++ b/net/ipv4/arp.c
@@ -777,7 +777,7 @@ static int arp_process(struct sk_buff *skb)
777 * Check for bad requests for 127.x.x.x and requests for multicast 777 * Check for bad requests for 127.x.x.x and requests for multicast
778 * addresses. If this is one such, delete it. 778 * addresses. If this is one such, delete it.
779 */ 779 */
780 if (LOOPBACK(tip) || MULTICAST(tip)) 780 if (ipv4_is_loopback(tip) || ipv4_is_multicast(tip))
781 goto out; 781 goto out;
782 782
783/* 783/*
diff --git a/net/ipv4/datagram.c b/net/ipv4/datagram.c
index 0301dd468cf4..0c0c73f368ce 100644
--- a/net/ipv4/datagram.c
+++ b/net/ipv4/datagram.c
@@ -40,7 +40,7 @@ int ip4_datagram_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len)
40 40
41 oif = sk->sk_bound_dev_if; 41 oif = sk->sk_bound_dev_if;
42 saddr = inet->saddr; 42 saddr = inet->saddr;
43 if (MULTICAST(usin->sin_addr.s_addr)) { 43 if (ipv4_is_multicast(usin->sin_addr.s_addr)) {
44 if (!oif) 44 if (!oif)
45 oif = inet->mc_index; 45 oif = inet->mc_index;
46 if (!saddr) 46 if (!saddr)
diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
index 1f21f4a2df86..44cb252d2f61 100644
--- a/net/ipv4/devinet.c
+++ b/net/ipv4/devinet.c
@@ -404,7 +404,7 @@ static int inet_set_ifa(struct net_device *dev, struct in_ifaddr *ifa)
404 in_dev_hold(in_dev); 404 in_dev_hold(in_dev);
405 ifa->ifa_dev = in_dev; 405 ifa->ifa_dev = in_dev;
406 } 406 }
407 if (LOOPBACK(ifa->ifa_local)) 407 if (ipv4_is_loopback(ifa->ifa_local))
408 ifa->ifa_scope = RT_SCOPE_HOST; 408 ifa->ifa_scope = RT_SCOPE_HOST;
409 return inet_insert_ifa(ifa); 409 return inet_insert_ifa(ifa);
410} 410}
@@ -583,7 +583,7 @@ static __inline__ int inet_abc_len(__be32 addr)
583{ 583{
584 int rc = -1; /* Something else, probably a multicast. */ 584 int rc = -1; /* Something else, probably a multicast. */
585 585
586 if (ZERONET(addr)) 586 if (ipv4_is_zeronet(addr))
587 rc = 0; 587 rc = 0;
588 else { 588 else {
589 __u32 haddr = ntohl(addr); 589 __u32 haddr = ntohl(addr);
diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
index d90b42f3630c..ac6238a3b0fd 100644
--- a/net/ipv4/fib_frontend.c
+++ b/net/ipv4/fib_frontend.c
@@ -167,9 +167,9 @@ static inline unsigned __inet_dev_addr_type(const struct net_device *dev,
167 unsigned ret = RTN_BROADCAST; 167 unsigned ret = RTN_BROADCAST;
168 struct fib_table *local_table; 168 struct fib_table *local_table;
169 169
170 if (ZERONET(addr) || BADCLASS(addr)) 170 if (ipv4_is_zeronet(addr) || ipv4_is_badclass(addr))
171 return RTN_BROADCAST; 171 return RTN_BROADCAST;
172 if (MULTICAST(addr)) 172 if (ipv4_is_multicast(addr))
173 return RTN_MULTICAST; 173 return RTN_MULTICAST;
174 174
175#ifdef CONFIG_IP_MULTIPLE_TABLES 175#ifdef CONFIG_IP_MULTIPLE_TABLES
@@ -710,7 +710,7 @@ void fib_add_ifaddr(struct in_ifaddr *ifa)
710 if (ifa->ifa_broadcast && ifa->ifa_broadcast != htonl(0xFFFFFFFF)) 710 if (ifa->ifa_broadcast && ifa->ifa_broadcast != htonl(0xFFFFFFFF))
711 fib_magic(RTM_NEWROUTE, RTN_BROADCAST, ifa->ifa_broadcast, 32, prim); 711 fib_magic(RTM_NEWROUTE, RTN_BROADCAST, ifa->ifa_broadcast, 32, prim);
712 712
713 if (!ZERONET(prefix) && !(ifa->ifa_flags&IFA_F_SECONDARY) && 713 if (!ipv4_is_zeronet(prefix) && !(ifa->ifa_flags&IFA_F_SECONDARY) &&
714 (prefix != addr || ifa->ifa_prefixlen < 32)) { 714 (prefix != addr || ifa->ifa_prefixlen < 32)) {
715 fib_magic(RTM_NEWROUTE, dev->flags&IFF_LOOPBACK ? RTN_LOCAL : 715 fib_magic(RTM_NEWROUTE, dev->flags&IFF_LOOPBACK ? RTN_LOCAL :
716 RTN_UNICAST, prefix, ifa->ifa_prefixlen, prim); 716 RTN_UNICAST, prefix, ifa->ifa_prefixlen, prim);
diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c
index d3d5906e1b3d..285d26218a51 100644
--- a/net/ipv4/igmp.c
+++ b/net/ipv4/igmp.c
@@ -1742,7 +1742,7 @@ int ip_mc_join_group(struct sock *sk , struct ip_mreqn *imr)
1742 int ifindex; 1742 int ifindex;
1743 int count = 0; 1743 int count = 0;
1744 1744
1745 if (!MULTICAST(addr)) 1745 if (!ipv4_is_multicast(addr))
1746 return -EINVAL; 1746 return -EINVAL;
1747 1747
1748 rtnl_lock(); 1748 rtnl_lock();
@@ -1855,7 +1855,7 @@ int ip_mc_source(int add, int omode, struct sock *sk, struct
1855 int leavegroup = 0; 1855 int leavegroup = 0;
1856 int i, j, rv; 1856 int i, j, rv;
1857 1857
1858 if (!MULTICAST(addr)) 1858 if (!ipv4_is_multicast(addr))
1859 return -EINVAL; 1859 return -EINVAL;
1860 1860
1861 rtnl_lock(); 1861 rtnl_lock();
@@ -1985,7 +1985,7 @@ int ip_mc_msfilter(struct sock *sk, struct ip_msfilter *msf, int ifindex)
1985 struct ip_sf_socklist *newpsl, *psl; 1985 struct ip_sf_socklist *newpsl, *psl;
1986 int leavegroup = 0; 1986 int leavegroup = 0;
1987 1987
1988 if (!MULTICAST(addr)) 1988 if (!ipv4_is_multicast(addr))
1989 return -EINVAL; 1989 return -EINVAL;
1990 if (msf->imsf_fmode != MCAST_INCLUDE && 1990 if (msf->imsf_fmode != MCAST_INCLUDE &&
1991 msf->imsf_fmode != MCAST_EXCLUDE) 1991 msf->imsf_fmode != MCAST_EXCLUDE)
@@ -2068,7 +2068,7 @@ int ip_mc_msfget(struct sock *sk, struct ip_msfilter *msf,
2068 struct inet_sock *inet = inet_sk(sk); 2068 struct inet_sock *inet = inet_sk(sk);
2069 struct ip_sf_socklist *psl; 2069 struct ip_sf_socklist *psl;
2070 2070
2071 if (!MULTICAST(addr)) 2071 if (!ipv4_is_multicast(addr))
2072 return -EINVAL; 2072 return -EINVAL;
2073 2073
2074 rtnl_lock(); 2074 rtnl_lock();
@@ -2130,7 +2130,7 @@ int ip_mc_gsfget(struct sock *sk, struct group_filter *gsf,
2130 if (psin->sin_family != AF_INET) 2130 if (psin->sin_family != AF_INET)
2131 return -EINVAL; 2131 return -EINVAL;
2132 addr = psin->sin_addr.s_addr; 2132 addr = psin->sin_addr.s_addr;
2133 if (!MULTICAST(addr)) 2133 if (!ipv4_is_multicast(addr))
2134 return -EINVAL; 2134 return -EINVAL;
2135 2135
2136 rtnl_lock(); 2136 rtnl_lock();
@@ -2180,7 +2180,7 @@ int ip_mc_sf_allow(struct sock *sk, __be32 loc_addr, __be32 rmt_addr, int dif)
2180 struct ip_sf_socklist *psl; 2180 struct ip_sf_socklist *psl;
2181 int i; 2181 int i;
2182 2182
2183 if (!MULTICAST(loc_addr)) 2183 if (!ipv4_is_multicast(loc_addr))
2184 return 1; 2184 return 1;
2185 2185
2186 for (pmc=inet->mc_list; pmc; pmc=pmc->next) { 2186 for (pmc=inet->mc_list; pmc; pmc=pmc->next) {
diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
index 0832f6e028b8..8b81deb8ff1f 100644
--- a/net/ipv4/ip_gre.c
+++ b/net/ipv4/ip_gre.c
@@ -176,7 +176,8 @@ static struct ip_tunnel * ipgre_tunnel_lookup(__be32 remote, __be32 local, __be3
176 } 176 }
177 for (t = tunnels_l[h1]; t; t = t->next) { 177 for (t = tunnels_l[h1]; t; t = t->next) {
178 if (local == t->parms.iph.saddr || 178 if (local == t->parms.iph.saddr ||
179 (local == t->parms.iph.daddr && MULTICAST(local))) { 179 (local == t->parms.iph.daddr &&
180 ipv4_is_multicast(local))) {
180 if (t->parms.i_key == key && (t->dev->flags&IFF_UP)) 181 if (t->parms.i_key == key && (t->dev->flags&IFF_UP))
181 return t; 182 return t;
182 } 183 }
@@ -201,7 +202,7 @@ static struct ip_tunnel **__ipgre_bucket(struct ip_tunnel_parm *parms)
201 202
202 if (local) 203 if (local)
203 prio |= 1; 204 prio |= 1;
204 if (remote && !MULTICAST(remote)) { 205 if (remote && !ipv4_is_multicast(remote)) {
205 prio |= 2; 206 prio |= 2;
206 h ^= HASH(remote); 207 h ^= HASH(remote);
207 } 208 }
@@ -367,7 +368,8 @@ static void ipgre_err(struct sk_buff *skb, u32 info)
367 368
368 read_lock(&ipgre_lock); 369 read_lock(&ipgre_lock);
369 t = ipgre_tunnel_lookup(iph->daddr, iph->saddr, (flags&GRE_KEY) ? *(((__be32*)p) + (grehlen>>2) - 1) : 0); 370 t = ipgre_tunnel_lookup(iph->daddr, iph->saddr, (flags&GRE_KEY) ? *(((__be32*)p) + (grehlen>>2) - 1) : 0);
370 if (t == NULL || t->parms.iph.daddr == 0 || MULTICAST(t->parms.iph.daddr)) 371 if (t == NULL || t->parms.iph.daddr == 0 ||
372 ipv4_is_multicast(t->parms.iph.daddr))
371 goto out; 373 goto out;
372 374
373 if (t->parms.iph.ttl == 0 && type == ICMP_TIME_EXCEEDED) 375 if (t->parms.iph.ttl == 0 && type == ICMP_TIME_EXCEEDED)
@@ -619,7 +621,7 @@ static int ipgre_rcv(struct sk_buff *skb)
619 skb_postpull_rcsum(skb, skb_transport_header(skb), offset); 621 skb_postpull_rcsum(skb, skb_transport_header(skb), offset);
620 skb->pkt_type = PACKET_HOST; 622 skb->pkt_type = PACKET_HOST;
621#ifdef CONFIG_NET_IPGRE_BROADCAST 623#ifdef CONFIG_NET_IPGRE_BROADCAST
622 if (MULTICAST(iph->daddr)) { 624 if (ipv4_is_multicast(iph->daddr)) {
623 /* Looped back packet, drop it! */ 625 /* Looped back packet, drop it! */
624 if (((struct rtable*)skb->dst)->fl.iif == 0) 626 if (((struct rtable*)skb->dst)->fl.iif == 0)
625 goto drop; 627 goto drop;
@@ -783,7 +785,8 @@ static int ipgre_tunnel_xmit(struct sk_buff *skb, struct net_device *dev)
783 struct rt6_info *rt6 = (struct rt6_info*)skb->dst; 785 struct rt6_info *rt6 = (struct rt6_info*)skb->dst;
784 786
785 if (rt6 && mtu < dst_mtu(skb->dst) && mtu >= IPV6_MIN_MTU) { 787 if (rt6 && mtu < dst_mtu(skb->dst) && mtu >= IPV6_MIN_MTU) {
786 if ((tunnel->parms.iph.daddr && !MULTICAST(tunnel->parms.iph.daddr)) || 788 if ((tunnel->parms.iph.daddr &&
789 !ipv4_is_multicast(tunnel->parms.iph.daddr)) ||
787 rt6->rt6i_dst.plen == 128) { 790 rt6->rt6i_dst.plen == 128) {
788 rt6->rt6i_flags |= RTF_MODIFIED; 791 rt6->rt6i_flags |= RTF_MODIFIED;
789 skb->dst->metrics[RTAX_MTU-1] = mtu; 792 skb->dst->metrics[RTAX_MTU-1] = mtu;
@@ -1009,7 +1012,7 @@ ipgre_tunnel_ioctl (struct net_device *dev, struct ifreq *ifr, int cmd)
1009 1012
1010 t = netdev_priv(dev); 1013 t = netdev_priv(dev);
1011 1014
1012 if (MULTICAST(p.iph.daddr)) 1015 if (ipv4_is_multicast(p.iph.daddr))
1013 nflags = IFF_BROADCAST; 1016 nflags = IFF_BROADCAST;
1014 else if (p.iph.daddr) 1017 else if (p.iph.daddr)
1015 nflags = IFF_POINTOPOINT; 1018 nflags = IFF_POINTOPOINT;
@@ -1143,7 +1146,7 @@ static int ipgre_header(struct sk_buff *skb, struct net_device *dev,
1143 memcpy(&iph->daddr, daddr, 4); 1146 memcpy(&iph->daddr, daddr, 4);
1144 return t->hlen; 1147 return t->hlen;
1145 } 1148 }
1146 if (iph->daddr && !MULTICAST(iph->daddr)) 1149 if (iph->daddr && !ipv4_is_multicast(iph->daddr))
1147 return t->hlen; 1150 return t->hlen;
1148 1151
1149 return -t->hlen; 1152 return -t->hlen;
@@ -1166,7 +1169,7 @@ static int ipgre_open(struct net_device *dev)
1166{ 1169{
1167 struct ip_tunnel *t = netdev_priv(dev); 1170 struct ip_tunnel *t = netdev_priv(dev);
1168 1171
1169 if (MULTICAST(t->parms.iph.daddr)) { 1172 if (ipv4_is_multicast(t->parms.iph.daddr)) {
1170 struct flowi fl = { .oif = t->parms.link, 1173 struct flowi fl = { .oif = t->parms.link,
1171 .nl_u = { .ip4_u = 1174 .nl_u = { .ip4_u =
1172 { .daddr = t->parms.iph.daddr, 1175 { .daddr = t->parms.iph.daddr,
@@ -1189,7 +1192,7 @@ static int ipgre_open(struct net_device *dev)
1189static int ipgre_close(struct net_device *dev) 1192static int ipgre_close(struct net_device *dev)
1190{ 1193{
1191 struct ip_tunnel *t = netdev_priv(dev); 1194 struct ip_tunnel *t = netdev_priv(dev);
1192 if (MULTICAST(t->parms.iph.daddr) && t->mlink) { 1195 if (ipv4_is_multicast(t->parms.iph.daddr) && t->mlink) {
1193 struct in_device *in_dev = inetdev_by_index(t->mlink); 1196 struct in_device *in_dev = inetdev_by_index(t->mlink);
1194 if (in_dev) { 1197 if (in_dev) {
1195 ip_mc_dec_group(in_dev, t->parms.iph.daddr); 1198 ip_mc_dec_group(in_dev, t->parms.iph.daddr);
@@ -1236,7 +1239,7 @@ static int ipgre_tunnel_init(struct net_device *dev)
1236 1239
1237 if (iph->daddr) { 1240 if (iph->daddr) {
1238#ifdef CONFIG_NET_IPGRE_BROADCAST 1241#ifdef CONFIG_NET_IPGRE_BROADCAST
1239 if (MULTICAST(iph->daddr)) { 1242 if (ipv4_is_multicast(iph->daddr)) {
1240 if (!iph->saddr) 1243 if (!iph->saddr)
1241 return -EINVAL; 1244 return -EINVAL;
1242 dev->flags = IFF_BROADCAST; 1245 dev->flags = IFF_BROADCAST;
diff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c
index 9947f523862e..772daf77878f 100644
--- a/net/ipv4/ipmr.c
+++ b/net/ipv4/ipmr.c
@@ -749,7 +749,7 @@ static int ipmr_mfc_add(struct mfcctl *mfc, int mrtsock)
749 return 0; 749 return 0;
750 } 750 }
751 751
752 if (!MULTICAST(mfc->mfcc_mcastgrp.s_addr)) 752 if (!ipv4_is_multicast(mfc->mfcc_mcastgrp.s_addr))
753 return -EINVAL; 753 return -EINVAL;
754 754
755 c=ipmr_cache_alloc(); 755 c=ipmr_cache_alloc();
@@ -1461,7 +1461,7 @@ int pim_rcv_v1(struct sk_buff * skb)
1461 b. packet is not a NULL-REGISTER 1461 b. packet is not a NULL-REGISTER
1462 c. packet is not truncated 1462 c. packet is not truncated
1463 */ 1463 */
1464 if (!MULTICAST(encap->daddr) || 1464 if (!ipv4_is_multicast(encap->daddr) ||
1465 encap->tot_len == 0 || 1465 encap->tot_len == 0 ||
1466 ntohs(encap->tot_len) + sizeof(*pim) > skb->len) 1466 ntohs(encap->tot_len) + sizeof(*pim) > skb->len)
1467 goto drop; 1467 goto drop;
@@ -1517,7 +1517,7 @@ static int pim_rcv(struct sk_buff * skb)
1517 /* check if the inner packet is destined to mcast group */ 1517 /* check if the inner packet is destined to mcast group */
1518 encap = (struct iphdr *)(skb_transport_header(skb) + 1518 encap = (struct iphdr *)(skb_transport_header(skb) +
1519 sizeof(struct pimreghdr)); 1519 sizeof(struct pimreghdr));
1520 if (!MULTICAST(encap->daddr) || 1520 if (!ipv4_is_multicast(encap->daddr) ||
1521 encap->tot_len == 0 || 1521 encap->tot_len == 0 ||
1522 ntohs(encap->tot_len) + sizeof(*pim) > skb->len) 1522 ntohs(encap->tot_len) + sizeof(*pim) > skb->len)
1523 goto drop; 1523 goto drop;
diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
index 2ff8214a530b..5aec5a5e5f16 100644
--- a/net/ipv4/raw.c
+++ b/net/ipv4/raw.c
@@ -530,7 +530,7 @@ static int raw_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
530 if (msg->msg_flags & MSG_DONTROUTE) 530 if (msg->msg_flags & MSG_DONTROUTE)
531 tos |= RTO_ONLINK; 531 tos |= RTO_ONLINK;
532 532
533 if (MULTICAST(daddr)) { 533 if (ipv4_is_multicast(daddr)) {
534 if (!ipc.oif) 534 if (!ipc.oif)
535 ipc.oif = inet->mc_index; 535 ipc.oif = inet->mc_index;
536 if (!saddr) 536 if (!saddr)
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index 36c7add8de84..1cc6c23cf758 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -1154,7 +1154,8 @@ void ip_rt_redirect(__be32 old_gw, __be32 daddr, __be32 new_gw,
1154 return; 1154 return;
1155 1155
1156 if (new_gw == old_gw || !IN_DEV_RX_REDIRECTS(in_dev) 1156 if (new_gw == old_gw || !IN_DEV_RX_REDIRECTS(in_dev)
1157 || MULTICAST(new_gw) || BADCLASS(new_gw) || ZERONET(new_gw)) 1157 || ipv4_is_multicast(new_gw) || ipv4_is_badclass(new_gw)
1158 || ipv4_is_zeronet(new_gw))
1158 goto reject_redirect; 1159 goto reject_redirect;
1159 1160
1160 if (!IN_DEV_SHARED_MEDIA(in_dev)) { 1161 if (!IN_DEV_SHARED_MEDIA(in_dev)) {
@@ -1633,12 +1634,12 @@ static int ip_route_input_mc(struct sk_buff *skb, __be32 daddr, __be32 saddr,
1633 if (in_dev == NULL) 1634 if (in_dev == NULL)
1634 return -EINVAL; 1635 return -EINVAL;
1635 1636
1636 if (MULTICAST(saddr) || BADCLASS(saddr) || LOOPBACK(saddr) || 1637 if (ipv4_is_multicast(saddr) || ipv4_is_badclass(saddr) ||
1637 skb->protocol != htons(ETH_P_IP)) 1638 ipv4_is_loopback(saddr) || skb->protocol != htons(ETH_P_IP))
1638 goto e_inval; 1639 goto e_inval;
1639 1640
1640 if (ZERONET(saddr)) { 1641 if (ipv4_is_zeronet(saddr)) {
1641 if (!LOCAL_MCAST(daddr)) 1642 if (!ipv4_is_local_multicast(daddr))
1642 goto e_inval; 1643 goto e_inval;
1643 spec_dst = inet_select_addr(dev, 0, RT_SCOPE_LINK); 1644 spec_dst = inet_select_addr(dev, 0, RT_SCOPE_LINK);
1644 } else if (fib_validate_source(saddr, 0, tos, 0, 1645 } else if (fib_validate_source(saddr, 0, tos, 0,
@@ -1680,7 +1681,7 @@ static int ip_route_input_mc(struct sk_buff *skb, __be32 daddr, __be32 saddr,
1680 } 1681 }
1681 1682
1682#ifdef CONFIG_IP_MROUTE 1683#ifdef CONFIG_IP_MROUTE
1683 if (!LOCAL_MCAST(daddr) && IN_DEV_MFORWARD(in_dev)) 1684 if (!ipv4_is_local_multicast(daddr) && IN_DEV_MFORWARD(in_dev))
1684 rth->u.dst.input = ip_mr_input; 1685 rth->u.dst.input = ip_mr_input;
1685#endif 1686#endif
1686 RT_CACHE_STAT_INC(in_slow_mc); 1687 RT_CACHE_STAT_INC(in_slow_mc);
@@ -1890,7 +1891,8 @@ static int ip_route_input_slow(struct sk_buff *skb, __be32 daddr, __be32 saddr,
1890 by fib_lookup. 1891 by fib_lookup.
1891 */ 1892 */
1892 1893
1893 if (MULTICAST(saddr) || BADCLASS(saddr) || LOOPBACK(saddr)) 1894 if (ipv4_is_multicast(saddr) || ipv4_is_badclass(saddr) ||
1895 ipv4_is_loopback(saddr))
1894 goto martian_source; 1896 goto martian_source;
1895 1897
1896 if (daddr == htonl(0xFFFFFFFF) || (saddr == 0 && daddr == 0)) 1898 if (daddr == htonl(0xFFFFFFFF) || (saddr == 0 && daddr == 0))
@@ -1899,10 +1901,11 @@ static int ip_route_input_slow(struct sk_buff *skb, __be32 daddr, __be32 saddr,
1899 /* Accept zero addresses only to limited broadcast; 1901 /* Accept zero addresses only to limited broadcast;
1900 * I even do not know to fix it or not. Waiting for complains :-) 1902 * I even do not know to fix it or not. Waiting for complains :-)
1901 */ 1903 */
1902 if (ZERONET(saddr)) 1904 if (ipv4_is_zeronet(saddr))
1903 goto martian_source; 1905 goto martian_source;
1904 1906
1905 if (BADCLASS(daddr) || ZERONET(daddr) || LOOPBACK(daddr)) 1907 if (ipv4_is_badclass(daddr) || ipv4_is_zeronet(daddr) ||
1908 ipv4_is_loopback(daddr))
1906 goto martian_destination; 1909 goto martian_destination;
1907 1910
1908 /* 1911 /*
@@ -1949,7 +1952,7 @@ brd_input:
1949 if (skb->protocol != htons(ETH_P_IP)) 1952 if (skb->protocol != htons(ETH_P_IP))
1950 goto e_inval; 1953 goto e_inval;
1951 1954
1952 if (ZERONET(saddr)) 1955 if (ipv4_is_zeronet(saddr))
1953 spec_dst = inet_select_addr(dev, 0, RT_SCOPE_LINK); 1956 spec_dst = inet_select_addr(dev, 0, RT_SCOPE_LINK);
1954 else { 1957 else {
1955 err = fib_validate_source(saddr, 0, tos, 0, dev, &spec_dst, 1958 err = fib_validate_source(saddr, 0, tos, 0, dev, &spec_dst,
@@ -2079,7 +2082,7 @@ int ip_route_input(struct sk_buff *skb, __be32 daddr, __be32 saddr,
2079 Note, that multicast routers are not affected, because 2082 Note, that multicast routers are not affected, because
2080 route cache entry is created eventually. 2083 route cache entry is created eventually.
2081 */ 2084 */
2082 if (MULTICAST(daddr)) { 2085 if (ipv4_is_multicast(daddr)) {
2083 struct in_device *in_dev; 2086 struct in_device *in_dev;
2084 2087
2085 rcu_read_lock(); 2088 rcu_read_lock();
@@ -2088,7 +2091,8 @@ int ip_route_input(struct sk_buff *skb, __be32 daddr, __be32 saddr,
2088 ip_hdr(skb)->protocol); 2091 ip_hdr(skb)->protocol);
2089 if (our 2092 if (our
2090#ifdef CONFIG_IP_MROUTE 2093#ifdef CONFIG_IP_MROUTE
2091 || (!LOCAL_MCAST(daddr) && IN_DEV_MFORWARD(in_dev)) 2094 || (!ipv4_is_local_multicast(daddr) &&
2095 IN_DEV_MFORWARD(in_dev))
2092#endif 2096#endif
2093 ) { 2097 ) {
2094 rcu_read_unlock(); 2098 rcu_read_unlock();
@@ -2114,14 +2118,14 @@ static inline int __mkroute_output(struct rtable **result,
2114 u32 tos = RT_FL_TOS(oldflp); 2118 u32 tos = RT_FL_TOS(oldflp);
2115 int err = 0; 2119 int err = 0;
2116 2120
2117 if (LOOPBACK(fl->fl4_src) && !(dev_out->flags&IFF_LOOPBACK)) 2121 if (ipv4_is_loopback(fl->fl4_src) && !(dev_out->flags&IFF_LOOPBACK))
2118 return -EINVAL; 2122 return -EINVAL;
2119 2123
2120 if (fl->fl4_dst == htonl(0xFFFFFFFF)) 2124 if (fl->fl4_dst == htonl(0xFFFFFFFF))
2121 res->type = RTN_BROADCAST; 2125 res->type = RTN_BROADCAST;
2122 else if (MULTICAST(fl->fl4_dst)) 2126 else if (ipv4_is_multicast(fl->fl4_dst))
2123 res->type = RTN_MULTICAST; 2127 res->type = RTN_MULTICAST;
2124 else if (BADCLASS(fl->fl4_dst) || ZERONET(fl->fl4_dst)) 2128 else if (ipv4_is_badclass(fl->fl4_dst) || ipv4_is_zeronet(fl->fl4_dst))
2125 return -EINVAL; 2129 return -EINVAL;
2126 2130
2127 if (dev_out->flags & IFF_LOOPBACK) 2131 if (dev_out->flags & IFF_LOOPBACK)
@@ -2201,7 +2205,7 @@ static inline int __mkroute_output(struct rtable **result,
2201#ifdef CONFIG_IP_MROUTE 2205#ifdef CONFIG_IP_MROUTE
2202 if (res->type == RTN_MULTICAST) { 2206 if (res->type == RTN_MULTICAST) {
2203 if (IN_DEV_MFORWARD(in_dev) && 2207 if (IN_DEV_MFORWARD(in_dev) &&
2204 !LOCAL_MCAST(oldflp->fl4_dst)) { 2208 !ipv4_is_local_multicast(oldflp->fl4_dst)) {
2205 rth->u.dst.input = ip_mr_input; 2209 rth->u.dst.input = ip_mr_input;
2206 rth->u.dst.output = ip_mc_output; 2210 rth->u.dst.output = ip_mc_output;
2207 } 2211 }
@@ -2271,9 +2275,9 @@ static int ip_route_output_slow(struct rtable **rp, const struct flowi *oldflp)
2271 2275
2272 if (oldflp->fl4_src) { 2276 if (oldflp->fl4_src) {
2273 err = -EINVAL; 2277 err = -EINVAL;
2274 if (MULTICAST(oldflp->fl4_src) || 2278 if (ipv4_is_multicast(oldflp->fl4_src) ||
2275 BADCLASS(oldflp->fl4_src) || 2279 ipv4_is_badclass(oldflp->fl4_src) ||
2276 ZERONET(oldflp->fl4_src)) 2280 ipv4_is_zeronet(oldflp->fl4_src))
2277 goto out; 2281 goto out;
2278 2282
2279 /* It is equivalent to inet_addr_type(saddr) == RTN_LOCAL */ 2283 /* It is equivalent to inet_addr_type(saddr) == RTN_LOCAL */
@@ -2290,7 +2294,8 @@ static int ip_route_output_slow(struct rtable **rp, const struct flowi *oldflp)
2290 */ 2294 */
2291 2295
2292 if (oldflp->oif == 0 2296 if (oldflp->oif == 0
2293 && (MULTICAST(oldflp->fl4_dst) || oldflp->fl4_dst == htonl(0xFFFFFFFF))) { 2297 && (ipv4_is_multicast(oldflp->fl4_dst) ||
2298 oldflp->fl4_dst == htonl(0xFFFFFFFF))) {
2294 /* Special hack: user can direct multicasts 2299 /* Special hack: user can direct multicasts
2295 and limited broadcast via necessary interface 2300 and limited broadcast via necessary interface
2296 without fiddling with IP_MULTICAST_IF or IP_PKTINFO. 2301 without fiddling with IP_MULTICAST_IF or IP_PKTINFO.
@@ -2327,14 +2332,15 @@ static int ip_route_output_slow(struct rtable **rp, const struct flowi *oldflp)
2327 goto out; /* Wrong error code */ 2332 goto out; /* Wrong error code */
2328 } 2333 }
2329 2334
2330 if (LOCAL_MCAST(oldflp->fl4_dst) || oldflp->fl4_dst == htonl(0xFFFFFFFF)) { 2335 if (ipv4_is_local_multicast(oldflp->fl4_dst) ||
2336 oldflp->fl4_dst == htonl(0xFFFFFFFF)) {
2331 if (!fl.fl4_src) 2337 if (!fl.fl4_src)
2332 fl.fl4_src = inet_select_addr(dev_out, 0, 2338 fl.fl4_src = inet_select_addr(dev_out, 0,
2333 RT_SCOPE_LINK); 2339 RT_SCOPE_LINK);
2334 goto make_route; 2340 goto make_route;
2335 } 2341 }
2336 if (!fl.fl4_src) { 2342 if (!fl.fl4_src) {
2337 if (MULTICAST(oldflp->fl4_dst)) 2343 if (ipv4_is_multicast(oldflp->fl4_dst))
2338 fl.fl4_src = inet_select_addr(dev_out, 0, 2344 fl.fl4_src = inet_select_addr(dev_out, 0,
2339 fl.fl4_scope); 2345 fl.fl4_scope);
2340 else if (!oldflp->fl4_dst) 2346 else if (!oldflp->fl4_dst)
@@ -2618,7 +2624,7 @@ static int rt_fill_info(struct sk_buff *skb, u32 pid, u32 seq, int event,
2618#ifdef CONFIG_IP_MROUTE 2624#ifdef CONFIG_IP_MROUTE
2619 __be32 dst = rt->rt_dst; 2625 __be32 dst = rt->rt_dst;
2620 2626
2621 if (MULTICAST(dst) && !LOCAL_MCAST(dst) && 2627 if (ipv4_is_multicast(dst) && !ipv4_is_local_multicast(dst) &&
2622 IPV4_DEVCONF_ALL(&init_net, MC_FORWARDING)) { 2628 IPV4_DEVCONF_ALL(&init_net, MC_FORWARDING)) {
2623 int err = ipmr_get_route(skb, r, nowait); 2629 int err = ipmr_get_route(skb, r, nowait);
2624 if (err <= 0) { 2630 if (err <= 0) {
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index 3d6021585658..1ce6b60b7f93 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -626,7 +626,7 @@ int udp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
626 connected = 0; 626 connected = 0;
627 } 627 }
628 628
629 if (MULTICAST(daddr)) { 629 if (ipv4_is_multicast(daddr)) {
630 if (!ipc.oif) 630 if (!ipc.oif)
631 ipc.oif = inet->mc_index; 631 ipc.oif = inet->mc_index;
632 if (!saddr) 632 if (!saddr)