* [PATCH 1/4] [IPv6] Add link and site-local scope inline
[not found] <11758281863002-git-send-email-brian.haley@hp.com>
@ 2007-04-06 3:21 ` Brian Haley
2007-04-06 3:24 ` YOSHIFUJI Hideaki / 吉藤英明
[not found] ` <117582818660-git-send-email-brian.haley@hp.com>
1 sibling, 1 reply; 11+ messages in thread
From: Brian Haley @ 2007-04-06 3:21 UTC (permalink / raw)
To: David Miller, YOSHIFUJI Hideaki; +Cc: netdev, dccp, lksctp-developers
Add link and site-local scope inline to avoid calls to ipv6_addr_type().
Signed-off-by: Brian Haley <brian.haley@hp.com>
---
include/net/ipv6.h | 10 ++++++++++
net/dccp/ipv6.c | 2 +-
net/ipv6/addrconf.c | 6 +++---
net/ipv6/af_inet6.c | 2 +-
net/ipv6/datagram.c | 11 ++++-------
net/ipv6/inet6_connection_sock.c | 2 +-
net/ipv6/ip6_output.c | 2 +-
net/ipv6/mcast.c | 8 +++-----
net/ipv6/ndisc.c | 8 ++++----
net/ipv6/raw.c | 4 ++--
net/ipv6/tcp_ipv6.c | 2 +-
net/ipv6/udp.c | 4 ++--
net/sctp/ipv6.c | 16 +++++++---------
13 files changed, 40 insertions(+), 37 deletions(-)
diff --git a/include/net/ipv6.h b/include/net/ipv6.h
index 00328b7..d473789 100644
--- a/include/net/ipv6.h
+++ b/include/net/ipv6.h
@@ -429,6 +429,16 @@ static inline int ipv6_addr_diff(const struct in6_addr *a1, const struct in6_add
return __ipv6_addr_diff(a1, a2, sizeof(struct in6_addr));
}
+static inline int ipv6_addr_scope_linklocal(const struct in6_addr *a)
+{
+ return ((a->s6_addr32[0] & htonl(0xFFC00000)) == htonl(0xFE800000));
+}
+
+static inline int ipv6_addr_scope_sitelocal(const struct in6_addr *a)
+{
+ return ((a->s6_addr32[0] & htonl(0xFFC00000)) == htonl(0xFEC00000));
+}
+
/*
* Prototypes exported by ipv6
*/
diff --git a/net/dccp/ipv6.c b/net/dccp/ipv6.c
index 64eac25..14a0f12 100644
--- a/net/dccp/ipv6.c
+++ b/net/dccp/ipv6.c
@@ -476,7 +476,7 @@ static int dccp_v6_conn_request(struct sock *sk, struct sk_buff *skb)
/* So that link locals have meaning */
if (!sk->sk_bound_dev_if &&
- ipv6_addr_type(&ireq6->rmt_addr) & IPV6_ADDR_LINKLOCAL)
+ ipv6_addr_scope_linklocal(&ireq6->rmt_addr))
ireq6->iif = inet6_iif(skb);
/*
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index 47d3adf..2d4fe24 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -2634,7 +2634,7 @@ static void addrconf_dad_completed(struct inet6_ifaddr *ifp)
if (ifp->idev->cnf.forwarding == 0 &&
ifp->idev->cnf.rtr_solicits > 0 &&
(dev->flags&IFF_LOOPBACK) == 0 &&
- (ipv6_addr_type(&ifp->addr) & IPV6_ADDR_LINKLOCAL)) {
+ ipv6_addr_scope_linklocal(&ifp->addr)) {
struct in6_addr all_routers;
ipv6_addr_all_routers(&all_routers);
@@ -3155,7 +3155,7 @@ static int inet6_fill_ifmcaddr(struct sk_buff *skb, struct ifmcaddr6 *ifmca,
u8 scope = RT_SCOPE_UNIVERSE;
int ifindex = ifmca->idev->dev->ifindex;
- if (ipv6_addr_scope(&ifmca->mca_addr) & IFA_SITE)
+ if (ipv6_addr_scope_sitelocal(&ifmca->mca_addr))
scope = RT_SCOPE_SITE;
nlh = nlmsg_put(skb, pid, seq, event, sizeof(struct ifaddrmsg), flags);
@@ -3180,7 +3180,7 @@ static int inet6_fill_ifacaddr(struct sk_buff *skb, struct ifacaddr6 *ifaca,
u8 scope = RT_SCOPE_UNIVERSE;
int ifindex = ifaca->aca_idev->dev->ifindex;
- if (ipv6_addr_scope(&ifaca->aca_addr) & IFA_SITE)
+ if (ipv6_addr_scope_sitelocal(&ifaca->aca_addr))
scope = RT_SCOPE_SITE;
nlh = nlmsg_put(skb, pid, seq, event, sizeof(struct ifaddrmsg), flags);
diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c
index df31cdd..24618cf 100644
--- a/net/ipv6/af_inet6.c
+++ b/net/ipv6/af_inet6.c
@@ -431,7 +431,7 @@ int inet6_getname(struct socket *sock, struct sockaddr *uaddr,
sin->sin6_port = inet->sport;
}
- if (ipv6_addr_type(&sin->sin6_addr) & IPV6_ADDR_LINKLOCAL)
+ if (ipv6_addr_scope_linklocal(&sin->sin6_addr))
sin->sin6_scope_id = sk->sk_bound_dev_if;
*uaddr_len = sizeof(*sin);
return(0);
diff --git a/net/ipv6/datagram.c b/net/ipv6/datagram.c
index 4a355fe..a8612b2 100644
--- a/net/ipv6/datagram.c
+++ b/net/ipv6/datagram.c
@@ -323,7 +323,7 @@ int ipv6_recv_error(struct sock *sk, struct msghdr *msg, int len)
sin->sin6_flowinfo =
(*(__be32 *)(nh + serr->addr_offset - 24) &
IPV6_FLOWINFO_MASK);
- if (ipv6_addr_type(&sin->sin6_addr) & IPV6_ADDR_LINKLOCAL)
+ if (ipv6_addr_scope_linklocal(&sin->sin6_addr))
sin->sin6_scope_id = IP6CB(skb)->iif;
} else {
ipv6_addr_set(&sin->sin6_addr, 0, 0,
@@ -343,7 +343,7 @@ int ipv6_recv_error(struct sock *sk, struct msghdr *msg, int len)
ipv6_addr_copy(&sin->sin6_addr, &ipv6_hdr(skb)->saddr);
if (np->rxopt.all)
datagram_recv_ctl(sk, msg, skb);
- if (ipv6_addr_type(&sin->sin6_addr) & IPV6_ADDR_LINKLOCAL)
+ if (ipv6_addr_scope_linklocal(&sin->sin6_addr))
sin->sin6_scope_id = IP6CB(skb)->iif;
} else {
struct inet_sock *inet = inet_sk(sk);
@@ -504,7 +504,6 @@ int datagram_send_ctl(struct msghdr *msg, struct flowi *fl,
int err = 0;
for (cmsg = CMSG_FIRSTHDR(msg); cmsg; cmsg = CMSG_NXTHDR(msg, cmsg)) {
- int addr_type;
struct net_device *dev = NULL;
if (!CMSG_OK(msg, cmsg)) {
@@ -531,12 +530,10 @@ int datagram_send_ctl(struct msghdr *msg, struct flowi *fl,
fl->oif = src_info->ipi6_ifindex;
}
- addr_type = ipv6_addr_type(&src_info->ipi6_addr);
-
- if (addr_type == IPV6_ADDR_ANY)
+ if (ipv6_addr_any(&src_info->ipi6_addr))
break;
- if (addr_type & IPV6_ADDR_LINKLOCAL) {
+ if (ipv6_addr_scope_linklocal(&src_info->ipi6_addr)) {
if (!src_info->ipi6_ifindex)
return -EINVAL;
else {
diff --git a/net/ipv6/inet6_connection_sock.c b/net/ipv6/inet6_connection_sock.c
index 116f94a..7cefe18 100644
--- a/net/ipv6/inet6_connection_sock.c
+++ b/net/ipv6/inet6_connection_sock.c
@@ -133,7 +133,7 @@ void inet6_csk_addr2sockaddr(struct sock *sk, struct sockaddr * uaddr)
sin6->sin6_flowinfo = 0;
sin6->sin6_scope_id = 0;
if (sk->sk_bound_dev_if &&
- ipv6_addr_type(&sin6->sin6_addr) & IPV6_ADDR_LINKLOCAL)
+ ipv6_addr_scope_linklocal(&sin6->sin6_addr))
sin6->sin6_scope_id = sk->sk_bound_dev_if;
}
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
index 78317a4..f6aa338 100644
--- a/net/ipv6/ip6_output.c
+++ b/net/ipv6/ip6_output.c
@@ -351,7 +351,7 @@ static int ip6_forward_proxy_check(struct sk_buff *skb)
* address, so signal the sender and discard the packet. This
* behavior is clarified by the MIPv6 specification.
*/
- if (ipv6_addr_type(&hdr->daddr) & IPV6_ADDR_LINKLOCAL) {
+ if (ipv6_addr_scope_linklocal(&hdr->daddr)) {
dst_link_failure(skb);
return -1;
}
diff --git a/net/ipv6/mcast.c b/net/ipv6/mcast.c
index 6c27589..d2d31a2 100644
--- a/net/ipv6/mcast.c
+++ b/net/ipv6/mcast.c
@@ -1171,7 +1171,7 @@ int igmp6_event_query(struct sk_buff *skb)
len -= skb_network_header_len(skb);
/* Drop queries with not link local source */
- if (!(ipv6_addr_type(&ipv6_hdr(skb)->saddr) & IPV6_ADDR_LINKLOCAL))
+ if (!ipv6_addr_scope_linklocal(&ipv6_hdr(skb)->saddr))
return -EINVAL;
idev = in6_dev_get(skb->dev);
@@ -1286,7 +1286,6 @@ int igmp6_event_report(struct sk_buff *skb)
struct in6_addr *addrp;
struct inet6_dev *idev;
struct icmp6hdr *hdr;
- int addr_type;
/* Our own report looped back. Ignore it. */
if (skb->pkt_type == PACKET_LOOPBACK)
@@ -1303,9 +1302,8 @@ int igmp6_event_report(struct sk_buff *skb)
hdr = icmp6_hdr(skb);
/* Drop reports with not link local source */
- addr_type = ipv6_addr_type(&ipv6_hdr(skb)->saddr);
- if (addr_type != IPV6_ADDR_ANY &&
- !(addr_type&IPV6_ADDR_LINKLOCAL))
+ if (!ipv6_addr_any(&ipv6_hdr(skb)->saddr) &&
+ !ipv6_addr_scope_linklocal(&ipv6_hdr(skb)->saddr))
return -EINVAL;
addrp = (struct in6_addr *) (hdr + 1);
diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c
index b1cf708..b500011 100644
--- a/net/ipv6/ndisc.c
+++ b/net/ipv6/ndisc.c
@@ -1115,7 +1115,7 @@ static void ndisc_router_discovery(struct sk_buff *skb)
optlen = (skb->tail - skb->transport_header) - sizeof(struct ra_msg);
- if (!(ipv6_addr_type(&ipv6_hdr(skb)->saddr) & IPV6_ADDR_LINKLOCAL)) {
+ if (!ipv6_addr_scope_linklocal(&ipv6_hdr(skb)->saddr)) {
ND_PRINTK2(KERN_WARNING
"ICMPv6 RA: source address is not link-local.\n");
return;
@@ -1356,7 +1356,7 @@ static void ndisc_redirect_rcv(struct sk_buff *skb)
int optlen;
u8 *lladdr = NULL;
- if (!(ipv6_addr_type(&ipv6_hdr(skb)->saddr) & IPV6_ADDR_LINKLOCAL)) {
+ if (!ipv6_addr_scope_linklocal(&ipv6_hdr(skb)->saddr)) {
ND_PRINTK2(KERN_WARNING
"ICMPv6 Redirect: source address is not link-local.\n");
return;
@@ -1383,7 +1383,7 @@ static void ndisc_redirect_rcv(struct sk_buff *skb)
if (ipv6_addr_equal(dest, target)) {
on_link = 1;
- } else if (!(ipv6_addr_type(target) & IPV6_ADDR_LINKLOCAL)) {
+ } else if (!ipv6_addr_scope_linklocal(target)) {
ND_PRINTK2(KERN_WARNING
"ICMPv6 Redirect: target address is not link-local.\n");
return;
@@ -1459,7 +1459,7 @@ void ndisc_send_redirect(struct sk_buff *skb, struct neighbour *neigh,
}
if (!ipv6_addr_equal(&ipv6_hdr(skb)->daddr, target) &&
- !(ipv6_addr_type(target) & IPV6_ADDR_LINKLOCAL)) {
+ !ipv6_addr_scope_linklocal(target)) {
ND_PRINTK2(KERN_WARNING
"ICMPv6 Redirect: target address is not link-local.\n");
return;
diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c
index 9592930..771fa0e 100644
--- a/net/ipv6/raw.c
+++ b/net/ipv6/raw.c
@@ -442,7 +442,7 @@ static int rawv6_recvmsg(struct kiocb *iocb, struct sock *sk,
ipv6_addr_copy(&sin6->sin6_addr, &ipv6_hdr(skb)->saddr);
sin6->sin6_flowinfo = 0;
sin6->sin6_scope_id = 0;
- if (ipv6_addr_type(&sin6->sin6_addr) & IPV6_ADDR_LINKLOCAL)
+ if (ipv6_addr_scope_linklocal(&sin6->sin6_addr))
sin6->sin6_scope_id = IP6CB(skb)->iif;
}
@@ -750,7 +750,7 @@ static int rawv6_sendmsg(struct kiocb *iocb, struct sock *sk,
if (addr_len >= sizeof(struct sockaddr_in6) &&
sin6->sin6_scope_id &&
- ipv6_addr_type(daddr)&IPV6_ADDR_LINKLOCAL)
+ ipv6_addr_scope_linklocal(daddr))
fl.oif = sin6->sin6_scope_id;
} else {
if (sk->sk_state != TCP_ESTABLISHED)
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index f0f7dc6..537978c 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -1287,7 +1287,7 @@ static int tcp_v6_conn_request(struct sock *sk, struct sk_buff *skb)
/* So that link locals have meaning */
if (!sk->sk_bound_dev_if &&
- ipv6_addr_type(&treq->rmt_addr) & IPV6_ADDR_LINKLOCAL)
+ ipv6_addr_scope_linklocal(&treq->rmt_addr))
treq->iif = inet6_iif(skb);
if (isn == 0)
diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
index bd2856f..c0b5fe3 100644
--- a/net/ipv6/udp.c
+++ b/net/ipv6/udp.c
@@ -182,7 +182,7 @@ try_again:
else {
ipv6_addr_copy(&sin6->sin6_addr,
&ipv6_hdr(skb)->saddr);
- if (ipv6_addr_type(&sin6->sin6_addr) & IPV6_ADDR_LINKLOCAL)
+ if (ipv6_addr_scope_linklocal(&sin6->sin6_addr))
sin6->sin6_scope_id = IP6CB(skb)->iif;
}
@@ -680,7 +680,7 @@ do_udp_sendmsg:
if (addr_len >= sizeof(struct sockaddr_in6) &&
sin6->sin6_scope_id &&
- ipv6_addr_type(daddr)&IPV6_ADDR_LINKLOCAL)
+ ipv6_addr_scope_linklocal(daddr))
fl.oif = sin6->sin6_scope_id;
} else {
if (sk->sk_state != TCP_ESTABLISHED)
diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c
index 5b0cdda..c1f4a8f 100644
--- a/net/sctp/ipv6.c
+++ b/net/sctp/ipv6.c
@@ -199,7 +199,7 @@ static int sctp_v6_xmit(struct sk_buff *skb, struct sctp_transport *transport,
fl.fl6_flowlabel = np->flow_label;
IP6_ECN_flow_xmit(sk, fl.fl6_flowlabel);
- if (ipv6_addr_type(&fl.fl6_src) & IPV6_ADDR_LINKLOCAL)
+ if (ipv6_addr_scope_linklocal(&fl.fl6_src))
fl.oif = transport->saddr.v6.sin6_scope_id;
else
fl.oif = sk->sk_bound_dev_if;
@@ -231,7 +231,7 @@ static struct dst_entry *sctp_v6_get_dst(struct sctp_association *asoc,
memset(&fl, 0, sizeof(fl));
ipv6_addr_copy(&fl.fl6_dst, &daddr->v6.sin6_addr);
- if (ipv6_addr_type(&daddr->v6.sin6_addr) & IPV6_ADDR_LINKLOCAL)
+ if (ipv6_addr_scope_linklocal(&daddr->v6.sin6_addr))
fl.oif = daddr->v6.sin6_scope_id;
@@ -500,7 +500,7 @@ static int sctp_v6_cmp_addr(const union sctp_addr *addr1,
if (!ipv6_addr_equal(&addr1->v6.sin6_addr, &addr2->v6.sin6_addr))
return 0;
/* If this is a linklocal address, compare the scope_id. */
- if (ipv6_addr_type(&addr1->v6.sin6_addr) & IPV6_ADDR_LINKLOCAL) {
+ if (ipv6_addr_scope_linklocal(&addr1->v6.sin6_addr)) {
if (addr1->v6.sin6_scope_id && addr2->v6.sin6_scope_id &&
(addr1->v6.sin6_scope_id != addr2->v6.sin6_scope_id)) {
return 0;
@@ -749,7 +749,7 @@ static void sctp_inet6_event_msgname(struct sctp_ulpevent *event,
sin6from = &asoc->peer.primary_addr.v6;
ipv6_addr_copy(&sin6->sin6_addr, &sin6from->sin6_addr);
- if (ipv6_addr_type(&sin6->sin6_addr) & IPV6_ADDR_LINKLOCAL)
+ if (ipv6_addr_scope_linklocal(&sin6->sin6_addr))
sin6->sin6_scope_id = sin6from->sin6_scope_id;
}
}
@@ -777,7 +777,7 @@ static void sctp_inet6_skb_msgname(struct sk_buff *skb, char *msgname,
/* Otherwise, just copy the v6 address. */
ipv6_addr_copy(&sin6->sin6_addr, &ipv6_hdr(skb)->saddr);
- if (ipv6_addr_type(&sin6->sin6_addr) & IPV6_ADDR_LINKLOCAL) {
+ if (ipv6_addr_scope_linklocal(&sin6->sin6_addr)) {
struct sctp_ulpevent *ev = sctp_skb2event(skb);
sin6->sin6_scope_id = ev->iif;
}
@@ -835,10 +835,9 @@ static int sctp_inet6_bind_verify(struct sctp_sock *opt, union sctp_addr *addr)
if (addr->sa.sa_family != AF_INET6)
af = sctp_get_af_specific(addr->sa.sa_family);
else {
- int type = ipv6_addr_type(&addr->v6.sin6_addr);
struct net_device *dev;
- if (type & IPV6_ADDR_LINKLOCAL) {
+ if (ipv6_addr_scope_linklocal(&addr->v6.sin6_addr)) {
if (!addr->v6.sin6_scope_id)
return 0;
dev = dev_get_by_index(addr->v6.sin6_scope_id);
@@ -862,10 +861,9 @@ static int sctp_inet6_send_verify(struct sctp_sock *opt, union sctp_addr *addr)
if (addr->sa.sa_family != AF_INET6)
af = sctp_get_af_specific(addr->sa.sa_family);
else {
- int type = ipv6_addr_type(&addr->v6.sin6_addr);
struct net_device *dev;
- if (type & IPV6_ADDR_LINKLOCAL) {
+ if (ipv6_addr_scope_linklocal(&addr->v6.sin6_addr)) {
if (!addr->v6.sin6_scope_id)
return 0;
dev = dev_get_by_index(addr->v6.sin6_scope_id);
--
1.5.0.3
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 2/4] [IPv6] Add multicast address type inline
[not found] ` <151538c13022864224f5ff440e1147f884abb492.1175794415.git.brian.haley@hp.com>
@ 2007-04-06 3:21 ` Brian Haley
2007-04-06 3:42 ` YOSHIFUJI Hideaki / 吉藤英明
2007-04-06 3:21 ` [PATCH 3/4] Add mapped " Brian Haley
2007-04-06 3:21 ` [PATCH 4/4] Add loopback " Brian Haley
2 siblings, 1 reply; 11+ messages in thread
From: Brian Haley @ 2007-04-06 3:21 UTC (permalink / raw)
To: David Miller, YOSHIFUJI Hideaki; +Cc: netdev
Add multicast address type inline to avoid calls to ipv6_addr_type().
Signed-off-by: Brian Haley <brian.haley@hp.com>
---
include/net/ipv6.h | 5 +++++
net/ipv6/icmp.c | 12 ++++--------
net/ipv6/ip6_tunnel.c | 4 ++--
net/ipv6/route.c | 4 ++--
4 files changed, 13 insertions(+), 12 deletions(-)
diff --git a/include/net/ipv6.h b/include/net/ipv6.h
index d473789..a888b0e 100644
--- a/include/net/ipv6.h
+++ b/include/net/ipv6.h
@@ -439,6 +439,11 @@ static inline int ipv6_addr_scope_sitelocal(const struct in6_addr *a)
return ((a->s6_addr32[0] & htonl(0xFFC00000)) == htonl(0xFEC00000));
}
+static inline int ipv6_addr_type_multicast(const struct in6_addr *a)
+{
+ return ((a->s6_addr32[0] & htonl(0xFF000000)) == htonl(0xFF000000));
+}
+
/*
* Prototypes exported by ipv6
*/
diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c
index e94992a..709037f 100644
--- a/net/ipv6/icmp.c
+++ b/net/ipv6/icmp.c
@@ -312,7 +312,6 @@ void icmpv6_send(struct sk_buff *skb, int type, int code, __u32 info,
struct flowi fl;
struct icmpv6_msg msg;
int iif = 0;
- int addr_type = 0;
int len;
int hlimit, tclass;
int err = 0;
@@ -327,8 +326,6 @@ void icmpv6_send(struct sk_buff *skb, int type, int code, __u32 info,
* Rule (e.1) is enforced by not using icmpv6_send
* in any code that processes icmp errors.
*/
- addr_type = ipv6_addr_type(&hdr->daddr);
-
if (ipv6_chk_addr(&hdr->daddr, skb->dev, 0))
saddr = &hdr->daddr;
@@ -336,7 +333,7 @@ void icmpv6_send(struct sk_buff *skb, int type, int code, __u32 info,
* Dest addr check
*/
- if ((addr_type & IPV6_ADDR_MULTICAST || skb->pkt_type != PACKET_HOST)) {
+ if (ipv6_addr_type_multicast(&hdr->daddr) || skb->pkt_type != PACKET_HOST) {
if (type != ICMPV6_PKT_TOOBIG &&
!(type == ICMPV6_PARAMPROB &&
code == ICMPV6_UNK_OPTION &&
@@ -346,13 +343,11 @@ void icmpv6_send(struct sk_buff *skb, int type, int code, __u32 info,
saddr = NULL;
}
- addr_type = ipv6_addr_type(&hdr->saddr);
-
/*
* Source addr check
*/
- if (addr_type & IPV6_ADDR_LINKLOCAL)
+ if (ipv6_addr_scope_linklocal(&hdr->saddr))
iif = skb->dev->ifindex;
/*
@@ -361,7 +356,8 @@ void icmpv6_send(struct sk_buff *skb, int type, int code, __u32 info,
* We check unspecified / multicast addresses here,
* and anycast addresses will be checked later.
*/
- if ((addr_type == IPV6_ADDR_ANY) || (addr_type & IPV6_ADDR_MULTICAST)) {
+ if (ipv6_addr_any(&hdr->saddr) ||
+ ipv6_addr_type_multicast(&hdr->saddr)) {
LIMIT_NETDEBUG(KERN_DEBUG "icmpv6_send: addr_any/mcast source\n");
return;
}
diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
index a0902fb..0dd1f63 100644
--- a/net/ipv6/ip6_tunnel.c
+++ b/net/ipv6/ip6_tunnel.c
@@ -1111,8 +1111,8 @@ static void ip6_tnl_link_config(struct ip6_tnl *t)
dev->iflink = p->link;
if (p->flags & IP6_TNL_F_CAP_XMIT) {
- int strict = (ipv6_addr_type(&p->raddr) &
- (IPV6_ADDR_MULTICAST|IPV6_ADDR_LINKLOCAL));
+ int strict = ipv6_addr_type_multicast(&p->raddr) ||
+ ipv6_addr_scope_linklocal(&p->raddr);
struct rt6_info *rt = rt6_lookup(&p->raddr, &p->laddr,
p->link, strict);
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 53d79ac..32c6398 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -227,8 +227,8 @@ static __inline__ int rt6_check_expired(const struct rt6_info *rt)
static inline int rt6_need_strict(struct in6_addr *daddr)
{
- return (ipv6_addr_type(daddr) &
- (IPV6_ADDR_MULTICAST | IPV6_ADDR_LINKLOCAL));
+ return (ipv6_addr_is_multicast(daddr) ||
+ ipv6_addr_scope_linklocal(daddr));
}
/*
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 3/4] Add mapped address type inline
[not found] ` <151538c13022864224f5ff440e1147f884abb492.1175794415.git.brian.haley@hp.com>
2007-04-06 3:21 ` [PATCH 2/4] [IPv6] Add multicast address type inline Brian Haley
@ 2007-04-06 3:21 ` Brian Haley
2007-04-06 3:47 ` YOSHIFUJI Hideaki / 吉藤英明
2007-04-06 3:21 ` [PATCH 4/4] Add loopback " Brian Haley
2 siblings, 1 reply; 11+ messages in thread
From: Brian Haley @ 2007-04-06 3:21 UTC (permalink / raw)
To: David Miller, YOSHIFUJI Hideaki; +Cc: netdev, lksctp-developers
Add mapped address type inline to avoid calls to ipv6_addr_type().
Signed-off-by: Brian Haley <brian.haley@hp.com>
---
include/net/ipv6.h | 6 ++++++
net/ipv6/ip6_flowlabel.c | 6 ++----
net/ipv6/ipv6_sockglue.c | 2 +-
net/ipv6/tcp_ipv6.c | 13 +++++--------
net/ipv6/udp.c | 2 +-
net/sctp/ipv6.c | 4 ++--
6 files changed, 17 insertions(+), 16 deletions(-)
diff --git a/include/net/ipv6.h b/include/net/ipv6.h
index a888b0e..f3e13db 100644
--- a/include/net/ipv6.h
+++ b/include/net/ipv6.h
@@ -444,6 +444,12 @@ static inline int ipv6_addr_type_multicast(const struct in6_addr *a)
return ((a->s6_addr32[0] & htonl(0xFF000000)) == htonl(0xFF000000));
}
+static inline int ipv6_addr_type_mapped(const struct in6_addr *a)
+{
+ return ((a->s6_addr32[0] | a->s6_addr32[1]) == 0 &&
+ a->s6_addr32[2] == htonl(0x0000ffff));
+}
+
/*
* Prototypes exported by ipv6
*/
diff --git a/net/ipv6/ip6_flowlabel.c b/net/ipv6/ip6_flowlabel.c
index c206a15..b1bd088 100644
--- a/net/ipv6/ip6_flowlabel.c
+++ b/net/ipv6/ip6_flowlabel.c
@@ -282,7 +282,6 @@ fl_create(struct in6_flowlabel_req *freq, char __user *optval, int optlen, int *
{
struct ip6_flowlabel *fl;
int olen;
- int addr_type;
int err;
err = -ENOMEM;
@@ -328,9 +327,8 @@ fl_create(struct in6_flowlabel_req *freq, char __user *optval, int optlen, int *
if (err)
goto done;
fl->share = freq->flr_share;
- addr_type = ipv6_addr_type(&freq->flr_dst);
- if ((addr_type&IPV6_ADDR_MAPPED)
- || addr_type == IPV6_ADDR_ANY) {
+ if (ipv6_addr_type_mapped(&freq->flr_dst) ||
+ ipv6_addr_any(&freq->flr_dst)) {
err = -EINVAL;
goto done;
}
diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
index aa3d07c..d83e982 100644
--- a/net/ipv6/ipv6_sockglue.c
+++ b/net/ipv6/ipv6_sockglue.c
@@ -249,7 +249,7 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname,
}
if (ipv6_only_sock(sk) ||
- !(ipv6_addr_type(&np->daddr) & IPV6_ADDR_MAPPED)) {
+ !ipv6_addr_type_mapped(&np->daddr)) {
retv = -EADDRNOTAVAIL;
break;
}
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index 537978c..a47d23d 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -132,7 +132,6 @@ static int tcp_v6_connect(struct sock *sk, struct sockaddr *uaddr,
struct in6_addr *saddr = NULL, *final_p = NULL, final;
struct flowi fl;
struct dst_entry *dst;
- int addr_type;
int err;
if (addr_len < SIN6_LEN_RFC2133)
@@ -163,12 +162,10 @@ static int tcp_v6_connect(struct sock *sk, struct sockaddr *uaddr,
if(ipv6_addr_any(&usin->sin6_addr))
usin->sin6_addr.s6_addr[15] = 0x1;
- addr_type = ipv6_addr_type(&usin->sin6_addr);
-
- if(addr_type & IPV6_ADDR_MULTICAST)
+ if (ipv6_addr_type_multicast(&usin->sin6_addr))
return -ENETUNREACH;
- if (addr_type&IPV6_ADDR_LINKLOCAL) {
+ if (ipv6_addr_scope_linklocal(&usin->sin6_addr)) {
if (addr_len >= sizeof(struct sockaddr_in6) &&
usin->sin6_scope_id) {
/* If interface is set while binding, indices
@@ -200,7 +197,7 @@ static int tcp_v6_connect(struct sock *sk, struct sockaddr *uaddr,
* TCP over IPv4
*/
- if (addr_type == IPV6_ADDR_MAPPED) {
+ if (ipv6_addr_type_mapped(&usin->sin6_addr)) {
u32 exthdrlen = icsk->icsk_ext_hdr_len;
struct sockaddr_in sin;
@@ -703,7 +703,7 @@ static int tcp_v6_parse_md5_keys (struct sock *sk, char __user *optval,
if (!cmd.tcpm_keylen) {
if (!tcp_sk(sk)->md5sig_info)
return -ENOENT;
- if (ipv6_addr_type(&sin6->sin6_addr) & IPV6_ADDR_MAPPED)
+ if (ipv6_addr_type_mapped(&sin6->sin6_addr))
return tcp_v4_md5_do_del(sk, sin6->sin6_addr.s6_addr32[3]);
return tcp_v6_md5_do_del(sk, &sin6->sin6_addr);
}
@@ -725,7 +725,7 @@ static int tcp_v6_parse_md5_keys (struct sock *sk, char __user *optval,
newkey = kmemdup(cmd.tcpm_key, cmd.tcpm_keylen, GFP_KERNEL);
if (!newkey)
return -ENOMEM;
- if (ipv6_addr_type(&sin6->sin6_addr) & IPV6_ADDR_MAPPED) {
+ if (ipv6_addr_type_mapped(&sin6->sin6_addr)) {
return tcp_v4_md5_do_add(sk, sin6->sin6_addr.s6_addr32[3],
newkey, cmd.tcpm_keylen);
}
diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
index c0b5fe3..6636431 100644
--- a/net/ipv6/udp.c
+++ b/net/ipv6/udp.c
@@ -610,7 +610,7 @@ int udpv6_sendmsg(struct kiocb *iocb, struct sock *sk,
daddr = NULL;
if (daddr) {
- if (ipv6_addr_type(daddr) == IPV6_ADDR_MAPPED) {
+ if (ipv6_addr_type_mapped(daddr)) {
struct sockaddr_in sin;
sin.sin_family = AF_INET;
sin.sin_port = sin6 ? sin6->sin6_port : inet->dport;
diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c
index c1f4a8f..af06d4b 100644
--- a/net/sctp/ipv6.c
+++ b/net/sctp/ipv6.c
@@ -481,7 +481,7 @@ static int sctp_v6_cmp_addr(const union sctp_addr *addr1,
if (addr1->sa.sa_family != addr2->sa.sa_family) {
if (addr1->sa.sa_family == AF_INET &&
addr2->sa.sa_family == AF_INET6 &&
- IPV6_ADDR_MAPPED == ipv6_addr_type(&addr2->v6.sin6_addr)) {
+ ipv6_addr_type_mapped(&addr2->v6.sin6_addr)) {
if (addr2->v6.sin6_port == addr1->v4.sin_port &&
addr2->v6.sin6_addr.s6_addr32[3] ==
addr1->v4.sin_addr.s_addr)
@@ -489,7 +489,7 @@ static int sctp_v6_cmp_addr(const union sctp_addr *addr1,
}
if (addr2->sa.sa_family == AF_INET &&
addr1->sa.sa_family == AF_INET6 &&
- IPV6_ADDR_MAPPED == ipv6_addr_type(&addr1->v6.sin6_addr)) {
+ ipv6_addr_type_mapped(&addr1->v6.sin6_addr)) {
if (addr1->v6.sin6_port == addr2->v4.sin_port &&
addr1->v6.sin6_addr.s6_addr32[3] ==
addr2->v4.sin_addr.s_addr)
--
1.5.0.3
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 4/4] Add loopback address type inline
[not found] ` <151538c13022864224f5ff440e1147f884abb492.1175794415.git.brian.haley@hp.com>
2007-04-06 3:21 ` [PATCH 2/4] [IPv6] Add multicast address type inline Brian Haley
2007-04-06 3:21 ` [PATCH 3/4] Add mapped " Brian Haley
@ 2007-04-06 3:21 ` Brian Haley
2007-04-06 3:51 ` YOSHIFUJI Hideaki / 吉藤英明
2 siblings, 1 reply; 11+ messages in thread
From: Brian Haley @ 2007-04-06 3:21 UTC (permalink / raw)
To: David Miller, YOSHIFUJI Hideaki; +Cc: netdev
Add loopback address type inline to avoid calls to ipv6_addr_type().
Signed-off-by: Brian Haley <brian.haley@hp.com>
---
include/net/ipv6.h | 7 +++++++
net/ipv6/ip6_output.c | 5 +++--
net/ipv6/route.c | 8 +++-----
3 files changed, 13 insertions(+), 7 deletions(-)
diff --git a/include/net/ipv6.h b/include/net/ipv6.h
index f3e13db..d87f421 100644
--- a/include/net/ipv6.h
+++ b/include/net/ipv6.h
@@ -388,6 +388,13 @@ static inline int ipv6_addr_any(const struct in6_addr *a)
a->s6_addr32[2] | a->s6_addr32[3] ) == 0);
}
+static inline int ipv6_addr_loopback(const struct in6_addr *a)
+{
+ return ((a->s6_addr32[0] | a->s6_addr32[1] |
+ a->s6_addr32[2] ) == 0 &&
+ a->s6_addr32[3] == htonl(0x00000001));
+}
+
/*
* find the first different bit between two addresses
* length of address must be a multiple of 32bits
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
index f6aa338..7f1aabe 100644
--- a/net/ipv6/ip6_output.c
+++ b/net/ipv6/ip6_output.c
@@ -455,8 +455,9 @@ int ip6_forward(struct sk_buff *skb)
*/
if (xrlim_allow(dst, 1*HZ))
ndisc_send_redirect(skb, n, target);
- } else if (ipv6_addr_type(&hdr->saddr)&(IPV6_ADDR_MULTICAST|IPV6_ADDR_LOOPBACK
- |IPV6_ADDR_LINKLOCAL)) {
+ } else if (ipv6_addr_type_multicast(&hdr->saddr) ||
+ ipv6_addr_loopback(&hdr->saddr) ||
+ ipv6_addr_scope_linklocal(&hdr->saddr)) {
/* This check is security critical. */
goto error;
}
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 32c6398..06ee92d 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -1067,7 +1067,6 @@ int ip6_route_add(struct fib6_config *cfg)
struct net_device *dev = NULL;
struct inet6_dev *idev = NULL;
struct fib6_table *table;
- int addr_type;
if (cfg->fc_dst_len > 128 || cfg->fc_src_len > 128)
return -EINVAL;
@@ -1108,9 +1107,7 @@ int ip6_route_add(struct fib6_config *cfg)
cfg->fc_protocol = RTPROT_BOOT;
rt->rt6i_protocol = cfg->fc_protocol;
- addr_type = ipv6_addr_type(&cfg->fc_dst);
-
- if (addr_type & IPV6_ADDR_MULTICAST)
+ if (ipv6_addr_type_multicast(&cfg->fc_dst))
rt->u.dst.input = ip6_mc_input;
else
rt->u.dst.input = ip6_forward;
@@ -1133,7 +1130,8 @@ int ip6_route_add(struct fib6_config *cfg)
they would result in kernel looping; promote them to reject routes
*/
if ((cfg->fc_flags & RTF_REJECT) ||
- (dev && (dev->flags&IFF_LOOPBACK) && !(addr_type&IPV6_ADDR_LOOPBACK))) {
+ (dev && (dev->flags&IFF_LOOPBACK) &&
+ !ipv6_addr_loopback(&cfg->fc_dst))) {
/* hold loopback dev/idev if we haven't done so. */
if (dev != &loopback_dev) {
if (dev) {
--
1.5.0.3
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH 1/4] [IPv6] Add link and site-local scope inline
2007-04-06 3:21 ` [PATCH 1/4] [IPv6] Add link and site-local scope inline Brian Haley
@ 2007-04-06 3:24 ` YOSHIFUJI Hideaki / 吉藤英明
2007-04-06 6:37 ` Brian Haley
0 siblings, 1 reply; 11+ messages in thread
From: YOSHIFUJI Hideaki / 吉藤英明 @ 2007-04-06 3:24 UTC (permalink / raw)
To: brian.haley; +Cc: davem, netdev, dccp, lksctp-developers
In article <4615BCA1.6000608@hp.com> (at Thu, 05 Apr 2007 23:21:05 -0400), Brian Haley <brian.haley@hp.com> says:
> Add link and site-local scope inline to avoid calls to ipv6_addr_type().
>
I disagree. Multicast scopes should also be handled appropriately.
--yoshfuji
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 2/4] [IPv6] Add multicast address type inline
2007-04-06 3:21 ` [PATCH 2/4] [IPv6] Add multicast address type inline Brian Haley
@ 2007-04-06 3:42 ` YOSHIFUJI Hideaki / 吉藤英明
0 siblings, 0 replies; 11+ messages in thread
From: YOSHIFUJI Hideaki / 吉藤英明 @ 2007-04-06 3:42 UTC (permalink / raw)
To: brian.haley; +Cc: davem, netdev
In article <4615BCAC.8010201@hp.com> (at Thu, 05 Apr 2007 23:21:16 -0400), Brian Haley <brian.haley@hp.com> says:
> Add multicast address type inline to avoid calls to ipv6_addr_type().
>
> Signed-off-by: Brian Haley <brian.haley@hp.com>
> ---
> include/net/ipv6.h | 5 +++++
> net/ipv6/icmp.c | 12 ++++--------
> net/ipv6/ip6_tunnel.c | 4 ++--
> net/ipv6/route.c | 4 ++--
> 4 files changed, 13 insertions(+), 12 deletions(-)
>
> diff --git a/include/net/ipv6.h b/include/net/ipv6.h
> index d473789..a888b0e 100644
> --- a/include/net/ipv6.h
> +++ b/include/net/ipv6.h
> @@ -439,6 +439,11 @@ static inline int ipv6_addr_scope_sitelocal(const struct in6_addr *a)
> return ((a->s6_addr32[0] & htonl(0xFFC00000)) == htonl(0xFEC00000));
> }
>
> +static inline int ipv6_addr_type_multicast(const struct in6_addr *a)
> +{
> + return ((a->s6_addr32[0] & htonl(0xFF000000)) == htonl(0xFF000000));
> +}
> +
Matter of taste, but I prefer ipv6_addr_multicast() to align
with ipv6_addr_any().
> diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c
> index e94992a..709037f 100644
> --- a/net/ipv6/icmp.c
> +++ b/net/ipv6/icmp.c
> @@ -312,7 +312,6 @@ void icmpv6_send(struct sk_buff *skb, int type, int code, __u32 info,
> struct flowi fl;
> struct icmpv6_msg msg;
> int iif = 0;
> - int addr_type = 0;
> int len;
> int hlimit, tclass;
> int err = 0;
> @@ -327,8 +326,6 @@ void icmpv6_send(struct sk_buff *skb, int type, int code, __u32 info,
> * Rule (e.1) is enforced by not using icmpv6_send
> * in any code that processes icmp errors.
> */
> - addr_type = ipv6_addr_type(&hdr->daddr);
> -
> if (ipv6_chk_addr(&hdr->daddr, skb->dev, 0))
> saddr = &hdr->daddr;
>
> @@ -336,7 +333,7 @@ void icmpv6_send(struct sk_buff *skb, int type, int code, __u32 info,
> * Dest addr check
> */
>
> - if ((addr_type & IPV6_ADDR_MULTICAST || skb->pkt_type != PACKET_HOST)) {
> + if (ipv6_addr_type_multicast(&hdr->daddr) || skb->pkt_type != PACKET_HOST) {
> if (type != ICMPV6_PKT_TOOBIG &&
> !(type == ICMPV6_PARAMPROB &&
> code == ICMPV6_UNK_OPTION &&
I think this is okay.
> @@ -346,13 +343,11 @@ void icmpv6_send(struct sk_buff *skb, int type, int code, __u32 info,
> saddr = NULL;
> }
>
> - addr_type = ipv6_addr_type(&hdr->saddr);
> -
> /*
> * Source addr check
> */
>
> - if (addr_type & IPV6_ADDR_LINKLOCAL)
> + if (ipv6_addr_scope_linklocal(&hdr->saddr))
> iif = skb->dev->ifindex;
>
> /*
No, this is not identical.
> @@ -361,7 +356,8 @@ void icmpv6_send(struct sk_buff *skb, int type, int code, __u32 info,
> * We check unspecified / multicast addresses here,
> * and anycast addresses will be checked later.
> */
> - if ((addr_type == IPV6_ADDR_ANY) || (addr_type & IPV6_ADDR_MULTICAST)) {
> + if (ipv6_addr_any(&hdr->saddr) ||
> + ipv6_addr_type_multicast(&hdr->saddr)) {
> LIMIT_NETDEBUG(KERN_DEBUG "icmpv6_send: addr_any/mcast source\n");
> return;
> }
I guess ipv6_addr_multicast() || ipv6_addr_any() is better.
> diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
> index a0902fb..0dd1f63 100644
> --- a/net/ipv6/ip6_tunnel.c
> +++ b/net/ipv6/ip6_tunnel.c
> @@ -1111,8 +1111,8 @@ static void ip6_tnl_link_config(struct ip6_tnl *t)
> dev->iflink = p->link;
>
> if (p->flags & IP6_TNL_F_CAP_XMIT) {
> - int strict = (ipv6_addr_type(&p->raddr) &
> - (IPV6_ADDR_MULTICAST|IPV6_ADDR_LINKLOCAL));
> + int strict = ipv6_addr_type_multicast(&p->raddr) ||
> + ipv6_addr_scope_linklocal(&p->raddr);
>
> struct rt6_info *rt = rt6_lookup(&p->raddr, &p->laddr,
> p->link, strict);
Different logic, but seems sane.
> diff --git a/net/ipv6/route.c b/net/ipv6/route.c
> index 53d79ac..32c6398 100644
> --- a/net/ipv6/route.c
> +++ b/net/ipv6/route.c
> @@ -227,8 +227,8 @@ static __inline__ int rt6_check_expired(const struct rt6_info *rt)
>
> static inline int rt6_need_strict(struct in6_addr *daddr)
> {
> - return (ipv6_addr_type(daddr) &
> - (IPV6_ADDR_MULTICAST | IPV6_ADDR_LINKLOCAL));
> + return (ipv6_addr_is_multicast(daddr) ||
> + ipv6_addr_scope_linklocal(daddr));
> }
>
ditto.
--yoshfuji
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 3/4] Add mapped address type inline
2007-04-06 3:21 ` [PATCH 3/4] Add mapped " Brian Haley
@ 2007-04-06 3:47 ` YOSHIFUJI Hideaki / 吉藤英明
0 siblings, 0 replies; 11+ messages in thread
From: YOSHIFUJI Hideaki / 吉藤英明 @ 2007-04-06 3:47 UTC (permalink / raw)
To: brian.haley; +Cc: davem, netdev, lksctp-developers
In article <4615BCB5.2020609@hp.com> (at Thu, 05 Apr 2007 23:21:25 -0400), Brian Haley <brian.haley@hp.com> says:
> Add mapped address type inline to avoid calls to ipv6_addr_type().
>
> Signed-off-by: Brian Haley <brian.haley@hp.com>
> ---
> include/net/ipv6.h | 6 ++++++
> net/ipv6/ip6_flowlabel.c | 6 ++----
> net/ipv6/ipv6_sockglue.c | 2 +-
> net/ipv6/tcp_ipv6.c | 13 +++++--------
> net/ipv6/udp.c | 2 +-
> net/sctp/ipv6.c | 4 ++--
> 6 files changed, 17 insertions(+), 16 deletions(-)
>
> diff --git a/include/net/ipv6.h b/include/net/ipv6.h
> index a888b0e..f3e13db 100644
> --- a/include/net/ipv6.h
> +++ b/include/net/ipv6.h
> @@ -444,6 +444,12 @@ static inline int ipv6_addr_type_multicast(const struct in6_addr *a)
> return ((a->s6_addr32[0] & htonl(0xFF000000)) == htonl(0xFF000000));
> }
>
> +static inline int ipv6_addr_type_mapped(const struct in6_addr *a)
> +{
> + return ((a->s6_addr32[0] | a->s6_addr32[1]) == 0 &&
> + a->s6_addr32[2] == htonl(0x0000ffff));
> +}
> +
> /*
> * Prototypes exported by ipv6
> */
I prefer ipv6_addr_v4mapped() to align with ipv6_addr_any()
(and IN6_IS_ADDR_V4MAPPED() macro in RFC3493).
> diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
> index 537978c..a47d23d 100644
> --- a/net/ipv6/tcp_ipv6.c
> +++ b/net/ipv6/tcp_ipv6.c
> @@ -132,7 +132,6 @@ static int tcp_v6_connect(struct sock *sk, struct sockaddr *uaddr,
> struct in6_addr *saddr = NULL, *final_p = NULL, final;
> struct flowi fl;
> struct dst_entry *dst;
> - int addr_type;
> int err;
>
> if (addr_len < SIN6_LEN_RFC2133)
> @@ -163,12 +162,10 @@ static int tcp_v6_connect(struct sock *sk, struct sockaddr *uaddr,
> if(ipv6_addr_any(&usin->sin6_addr))
> usin->sin6_addr.s6_addr[15] = 0x1;
>
> - addr_type = ipv6_addr_type(&usin->sin6_addr);
> -
> - if(addr_type & IPV6_ADDR_MULTICAST)
> + if (ipv6_addr_type_multicast(&usin->sin6_addr))
> return -ENETUNREACH;
>
> - if (addr_type&IPV6_ADDR_LINKLOCAL) {
> + if (ipv6_addr_scope_linklocal(&usin->sin6_addr)) {
> if (addr_len >= sizeof(struct sockaddr_in6) &&
> usin->sin6_scope_id) {
> /* If interface is set while binding, indices
> @@ -200,7 +197,7 @@ static int tcp_v6_connect(struct sock *sk, struct sockaddr *uaddr,
> * TCP over IPv4
> */
different commit?
--yoshfuji
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 4/4] Add loopback address type inline
2007-04-06 3:21 ` [PATCH 4/4] Add loopback " Brian Haley
@ 2007-04-06 3:51 ` YOSHIFUJI Hideaki / 吉藤英明
2007-04-06 6:38 ` Brian Haley
0 siblings, 1 reply; 11+ messages in thread
From: YOSHIFUJI Hideaki / 吉藤英明 @ 2007-04-06 3:51 UTC (permalink / raw)
To: brian.haley; +Cc: davem, netdev
In article <4615BCBD.2030607@hp.com> (at Thu, 05 Apr 2007 23:21:33 -0400), Brian Haley <brian.haley@hp.com> says:
> Add loopback address type inline to avoid calls to ipv6_addr_type().
> diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
> index f6aa338..7f1aabe 100644
> --- a/net/ipv6/ip6_output.c
> +++ b/net/ipv6/ip6_output.c
> @@ -455,8 +455,9 @@ int ip6_forward(struct sk_buff *skb)
> */
> if (xrlim_allow(dst, 1*HZ))
> ndisc_send_redirect(skb, n, target);
> - } else if (ipv6_addr_type(&hdr->saddr)&(IPV6_ADDR_MULTICAST|IPV6_ADDR_LOOPBACK
> - |IPV6_ADDR_LINKLOCAL)) {
> + } else if (ipv6_addr_type_multicast(&hdr->saddr) ||
> + ipv6_addr_loopback(&hdr->saddr) ||
> + ipv6_addr_scope_linklocal(&hdr->saddr)) {
> /* This check is security critical. */
> goto error;
> }
> diff --git a/net/ipv6/route.c b/net/ipv6/route.c
> index 32c6398..06ee92d 100644
> --- a/net/ipv6/route.c
> +++ b/net/ipv6/route.c
> @@ -1067,7 +1067,6 @@ int ip6_route_add(struct fib6_config *cfg)
> struct net_device *dev = NULL;
> struct inet6_dev *idev = NULL;
> struct fib6_table *table;
> - int addr_type;
>
> if (cfg->fc_dst_len > 128 || cfg->fc_src_len > 128)
> return -EINVAL;
> @@ -1108,9 +1107,7 @@ int ip6_route_add(struct fib6_config *cfg)
> cfg->fc_protocol = RTPROT_BOOT;
> rt->rt6i_protocol = cfg->fc_protocol;
>
> - addr_type = ipv6_addr_type(&cfg->fc_dst);
> -
> - if (addr_type & IPV6_ADDR_MULTICAST)
> + if (ipv6_addr_type_multicast(&cfg->fc_dst))
> rt->u.dst.input = ip6_mc_input;
> else
> rt->u.dst.input = ip6_forward;
different commit...
--yoshfuji
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 1/4] [IPv6] Add link and site-local scope inline
2007-04-06 3:24 ` YOSHIFUJI Hideaki / 吉藤英明
@ 2007-04-06 6:37 ` Brian Haley
2007-04-06 7:00 ` YOSHIFUJI Hideaki / 吉藤英明
0 siblings, 1 reply; 11+ messages in thread
From: Brian Haley @ 2007-04-06 6:37 UTC (permalink / raw)
To: YOSHIFUJI Hideaki / ????; +Cc: davem, netdev, dccp, lksctp-developers
YOSHIFUJI Hideaki / ???? wrote:
> In article <4615BCA1.6000608@hp.com> (at Thu, 05 Apr 2007 23:21:05 -0400), Brian Haley <brian.haley@hp.com> says:
>
>> Add link and site-local scope inline to avoid calls to ipv6_addr_type().
>>
>
> I disagree. Multicast scopes should also be handled appropriately.
Yes, I totally missed that
ipv6_addr_scope2type(IPV6_ADDR_MC_SCOPE(addr)) in __ipv6_addr_type(), so
the linklocal inline probably isn't worth it since it would have to be
something like:
static inline int ipv6_addr_scope_linklocal(const struct in6_addr *a)
{
return ((a->s6_addr32[0] & htonl(0xFFC00000)) == htonl(0xFE800000) ||
((a->s6_addr32[0] & htonl(0xFF000000)) == htonl(0xFF000000) &&
((a)->s6_addr[1] & 0x0f) == IPV6_ADDR_SCOPE_LINKLOCAL)))
}
That's not that clean an inline anymore, but still doable...
I'll clean-up the rest based on your comments and re-send.
-Brian
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 4/4] Add loopback address type inline
2007-04-06 3:51 ` YOSHIFUJI Hideaki / 吉藤英明
@ 2007-04-06 6:38 ` Brian Haley
0 siblings, 0 replies; 11+ messages in thread
From: Brian Haley @ 2007-04-06 6:38 UTC (permalink / raw)
To: YOSHIFUJI Hideaki / ????; +Cc: davem, netdev
YOSHIFUJI Hideaki / ???? wrote:
>> diff --git a/net/ipv6/route.c b/net/ipv6/route.c
>> index 32c6398..06ee92d 100644
>> --- a/net/ipv6/route.c
>> +++ b/net/ipv6/route.c
>> @@ -1067,7 +1067,6 @@ int ip6_route_add(struct fib6_config *cfg)
>> struct net_device *dev = NULL;
>> struct inet6_dev *idev = NULL;
>> struct fib6_table *table;
>> - int addr_type;
>>
>> if (cfg->fc_dst_len > 128 || cfg->fc_src_len > 128)
>> return -EINVAL;
>> @@ -1108,9 +1107,7 @@ int ip6_route_add(struct fib6_config *cfg)
>> cfg->fc_protocol = RTPROT_BOOT;
>> rt->rt6i_protocol = cfg->fc_protocol;
>>
>> - addr_type = ipv6_addr_type(&cfg->fc_dst);
>> -
>> - if (addr_type & IPV6_ADDR_MULTICAST)
>> + if (ipv6_addr_type_multicast(&cfg->fc_dst))
>> rt->u.dst.input = ip6_mc_input;
>> else
>> rt->u.dst.input = ip6_forward;
>
> different commit...
This and the previous patch were layered, and I couldn't add the rest of
this change without the loopback inline:
> @@ -1133,7 +1130,8 @@ int ip6_route_add(struct fib6_config *cfg)
> they would result in kernel looping; promote them to reject routes
> */
> if ((cfg->fc_flags & RTF_REJECT) ||
> - (dev && (dev->flags&IFF_LOOPBACK) && !(addr_type&IPV6_ADDR_LOOPBACK))) {
> + (dev && (dev->flags&IFF_LOOPBACK) &&
> + !ipv6_addr_loopback(&cfg->fc_dst))) {
> /* hold loopback dev/idev if we haven't done so. */
> if (dev != &loopback_dev) {
> if (dev) {
because they both used addr_type.
I'll put this all in one patch together next time so it's more obvious.
-Brian
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 1/4] [IPv6] Add link and site-local scope inline
2007-04-06 6:37 ` Brian Haley
@ 2007-04-06 7:00 ` YOSHIFUJI Hideaki / 吉藤英明
0 siblings, 0 replies; 11+ messages in thread
From: YOSHIFUJI Hideaki / 吉藤英明 @ 2007-04-06 7:00 UTC (permalink / raw)
To: brian.haley; +Cc: davem, netdev, dccp, lksctp-developers, yoshfuji
In article <4615EAC0.3080709@hp.com> (at Fri, 06 Apr 2007 02:37:52 -0400), Brian Haley <brian.haley@hp.com> says:
> static inline int ipv6_addr_scope_linklocal(const struct in6_addr *a)
> {
> return ((a->s6_addr32[0] & htonl(0xFFC00000)) == htonl(0xFE800000) ||
> ((a->s6_addr32[0] & htonl(0xFF000000)) == htonl(0xFF000000) &&
> ((a)->s6_addr[1] & 0x0f) == IPV6_ADDR_SCOPE_LINKLOCAL)))
> }
>
> That's not that clean an inline anymore, but still doable...
I would prefer to have ipv6_addr_linklocal() and
ipv6_addr_mc_linklocal() aligning with RFC3493.
--yoshfuji
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2007-04-06 7:11 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <11758281863002-git-send-email-brian.haley@hp.com>
2007-04-06 3:21 ` [PATCH 1/4] [IPv6] Add link and site-local scope inline Brian Haley
2007-04-06 3:24 ` YOSHIFUJI Hideaki / 吉藤英明
2007-04-06 6:37 ` Brian Haley
2007-04-06 7:00 ` YOSHIFUJI Hideaki / 吉藤英明
[not found] ` <117582818660-git-send-email-brian.haley@hp.com>
[not found] ` <11758281864173-git-send-email-brian.haley@hp.com>
[not found] ` <151538c13022864224f5ff440e1147f884abb492.1175794415.git.brian.haley@hp.com>
2007-04-06 3:21 ` [PATCH 2/4] [IPv6] Add multicast address type inline Brian Haley
2007-04-06 3:42 ` YOSHIFUJI Hideaki / 吉藤英明
2007-04-06 3:21 ` [PATCH 3/4] Add mapped " Brian Haley
2007-04-06 3:47 ` YOSHIFUJI Hideaki / 吉藤英明
2007-04-06 3:21 ` [PATCH 4/4] Add loopback " Brian Haley
2007-04-06 3:51 ` YOSHIFUJI Hideaki / 吉藤英明
2007-04-06 6:38 ` Brian Haley
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).