Re: [tipc-discussion] [PATCH net-next 3/3] tipc: use sock addr family to indicate IP version
Same for me. Acked-by: jon ///jon On 06/23/2016 06:23 AM, Xue, Ying wrote: > The other two patches look good for me. > > Regards, > Ying > > -Original Message- > From: Richard Alpe [mailto:richard.a...@ericsson.com] > Sent: Thursday, June 23, 2016 6:02 PM > To: Erik Hugne > Cc: tipc-discussion@lists.sourceforge.net > Subject: Re: [tipc-discussion] [PATCH net-next 3/3] tipc: use sock addr > family to indicate IP version > > On 2016-06-22 17:40, Erik Hugne wrote: >> This change is not backwards compatible, udp_media_addr is carried in >> the neighbor discovery messages. > You're right. I will drop this patch. > > /Richard > >> //E >> On Jun 22, 2016 10:03, "Richard Alpe" <richard.a...@ericsson.com> wrote: >> >>> Use socket address family instead of ethernet protocol ID to identify >>> IP version internally. >>> --- >>> net/tipc/udp_media.c | 26 +- >>> 1 file changed, 13 insertions(+), 13 deletions(-) >>> >>> diff --git a/net/tipc/udp_media.c b/net/tipc/udp_media.c index >>> b016c01..c7df8bd 100644 >>> --- a/net/tipc/udp_media.c >>> +++ b/net/tipc/udp_media.c >>> @@ -62,7 +62,7 @@ >>>* messages, and all fields should be in network byte order >>>*/ >>> struct udp_media_addr { >>> - __be16 proto; >>> + __kernel_sa_family_t family; >>> __be16 port; >>> union { >>> struct in_addr ipv4; >>> @@ -91,10 +91,10 @@ static void tipc_udp_media_addr_set(struct >>> tipc_media_addr *addr, >>> memset(addr, 0, sizeof(struct tipc_media_addr)); >>> addr->media_id = TIPC_MEDIA_TYPE_UDP; >>> memcpy(addr->value, ua, sizeof(struct udp_media_addr)); >>> - if (ntohs(ua->proto) == ETH_P_IP) { >>> + if (ua->family == AF_INET) { >>> if (ipv4_is_multicast(ua->ipv4.s_addr)) >>> addr->broadcast = 1; >>> - } else if (ntohs(ua->proto) == ETH_P_IPV6) { >>> + } else if (ua->family == AF_INET6) { >>> if (ipv6_addr_type(>ipv6) & IPV6_ADDR_MULTICAST) >>> addr->broadcast = 1; >>> } else { >>> @@ -107,9 +107,9 @@ static int tipc_udp_addr2str(struct >>> tipc_media_addr *a, char *buf, int size) { >>> struct udp_media_addr *ua = (struct udp_media_addr >>> *)>value; >>> >>> - if (ntohs(ua->proto) == ETH_P_IP) >>> + if (ua->family == AF_INET) >>> snprintf(buf, size, "%pI4:%u", >ipv4, ntohs(ua->port)); >>> - else if (ntohs(ua->proto) == ETH_P_IPV6) >>> + else if (ua->family == AF_INET6) >>> snprintf(buf, size, "%pI6:%u", >ipv6, ntohs(ua->port)); >>> else >>> pr_err("Invalid UDP media address\n"); @@ -162,7 >>> +162,7 @@ static int tipc_udp_send_msg(struct net *net, struct >>> sk_buff *skb, >>> err = -ENODEV; >>> goto tx_error; >>> } >>> - if (dst->proto == htons(ETH_P_IP)) { >>> + if (dst->family == AF_INET) { >>> struct flowi4 fl = { >>> .daddr = dst->ipv4.s_addr, >>> .saddr = src->ipv4.s_addr, @@ -240,7 +240,7 >>> @@ static int enable_mcast(struct udp_bearer *ub, struct >>> udp_media_addr *remote) >>> struct ip_mreqn mreqn; >>> struct sock *sk = ub->ubsock->sk; >>> >>> - if (ntohs(remote->proto) == ETH_P_IP) { >>> + if (remote->family == AF_INET) { >>> if (!ipv4_is_multicast(remote->ipv4.s_addr)) >>> return 0; >>> mreqn.imr_multiaddr = remote->ipv4; @@ -291,12 >>> +291,12 @@ err: >>> struct sockaddr_in *ip4; >>> >>> ip4 = (struct sockaddr_in *)_local; >>> - local->proto = htons(ETH_P_IP); >>> + local->family = AF_INET; >>> local->port = ip4->sin_port; >>> local->ipv4.s_addr = ip4->sin_addr.s_addr; >>> >>> ip4 = (struct sockaddr_in *)_remote; >>> - remote->proto = hton
Re: [tipc-discussion] [PATCH net-next 3/3] tipc: use sock addr family to indicate IP version
On 2016-06-22 17:40, Erik Hugne wrote: > This change is not backwards compatible, udp_media_addr is carried in the > neighbor discovery messages. You're right. I will drop this patch. /Richard > > //E > On Jun 22, 2016 10:03, "Richard Alpe"wrote: > >> Use socket address family instead of ethernet protocol ID to identify >> IP version internally. >> --- >> net/tipc/udp_media.c | 26 +- >> 1 file changed, 13 insertions(+), 13 deletions(-) >> >> diff --git a/net/tipc/udp_media.c b/net/tipc/udp_media.c >> index b016c01..c7df8bd 100644 >> --- a/net/tipc/udp_media.c >> +++ b/net/tipc/udp_media.c >> @@ -62,7 +62,7 @@ >> * messages, and all fields should be in network byte order >> */ >> struct udp_media_addr { >> - __be16 proto; >> + __kernel_sa_family_t family; >> __be16 port; >> union { >> struct in_addr ipv4; >> @@ -91,10 +91,10 @@ static void tipc_udp_media_addr_set(struct >> tipc_media_addr *addr, >> memset(addr, 0, sizeof(struct tipc_media_addr)); >> addr->media_id = TIPC_MEDIA_TYPE_UDP; >> memcpy(addr->value, ua, sizeof(struct udp_media_addr)); >> - if (ntohs(ua->proto) == ETH_P_IP) { >> + if (ua->family == AF_INET) { >> if (ipv4_is_multicast(ua->ipv4.s_addr)) >> addr->broadcast = 1; >> - } else if (ntohs(ua->proto) == ETH_P_IPV6) { >> + } else if (ua->family == AF_INET6) { >> if (ipv6_addr_type(>ipv6) & IPV6_ADDR_MULTICAST) >> addr->broadcast = 1; >> } else { >> @@ -107,9 +107,9 @@ static int tipc_udp_addr2str(struct tipc_media_addr >> *a, char *buf, int size) >> { >> struct udp_media_addr *ua = (struct udp_media_addr *)>value; >> >> - if (ntohs(ua->proto) == ETH_P_IP) >> + if (ua->family == AF_INET) >> snprintf(buf, size, "%pI4:%u", >ipv4, ntohs(ua->port)); >> - else if (ntohs(ua->proto) == ETH_P_IPV6) >> + else if (ua->family == AF_INET6) >> snprintf(buf, size, "%pI6:%u", >ipv6, ntohs(ua->port)); >> else >> pr_err("Invalid UDP media address\n"); >> @@ -162,7 +162,7 @@ static int tipc_udp_send_msg(struct net *net, struct >> sk_buff *skb, >> err = -ENODEV; >> goto tx_error; >> } >> - if (dst->proto == htons(ETH_P_IP)) { >> + if (dst->family == AF_INET) { >> struct flowi4 fl = { >> .daddr = dst->ipv4.s_addr, >> .saddr = src->ipv4.s_addr, >> @@ -240,7 +240,7 @@ static int enable_mcast(struct udp_bearer *ub, struct >> udp_media_addr *remote) >> struct ip_mreqn mreqn; >> struct sock *sk = ub->ubsock->sk; >> >> - if (ntohs(remote->proto) == ETH_P_IP) { >> + if (remote->family == AF_INET) { >> if (!ipv4_is_multicast(remote->ipv4.s_addr)) >> return 0; >> mreqn.imr_multiaddr = remote->ipv4; >> @@ -291,12 +291,12 @@ err: >> struct sockaddr_in *ip4; >> >> ip4 = (struct sockaddr_in *)_local; >> - local->proto = htons(ETH_P_IP); >> + local->family = AF_INET; >> local->port = ip4->sin_port; >> local->ipv4.s_addr = ip4->sin_addr.s_addr; >> >> ip4 = (struct sockaddr_in *)_remote; >> - remote->proto = htons(ETH_P_IP); >> + remote->family = AF_INET; >> remote->port = ip4->sin_port; >> remote->ipv4.s_addr = ip4->sin_addr.s_addr; >> return 0; >> @@ -311,13 +311,13 @@ err: >> if (__ipv6_addr_needs_scope_id(atype) && >> !ip6->sin6_scope_id) >> return -EINVAL; >> >> - local->proto = htons(ETH_P_IPV6); >> + local->family = AF_INET6; >> local->port = ip6->sin6_port; >> memcpy(>ipv6, >sin6_addr, sizeof(struct >> in6_addr)); >> ub->ifindex = ip6->sin6_scope_id; >> >> ip6 = (struct sockaddr_in6 *)_remote; >> - remote->proto = htons(ETH_P_IPV6); >> + remote->family = htons(ETH_P_IPV6); >> remote->port = ip6->sin6_port; >> memcpy(>ipv6, >sin6_addr, sizeof(struct >> in6_addr)); >> return 0; >> @@ -360,7 +360,7 @@ static int tipc_udp_enable(struct net *net, struct >> tipc_bearer *b, >> rcu_assign_pointer(b->media_ptr, ub); >> rcu_assign_pointer(ub->bearer, b); >> tipc_udp_media_addr_set(>addr, ); >> - if (local.proto == htons(ETH_P_IP)) { >> + if (local.family == AF_INET) { >> struct net_device *dev; >> >> dev = __ip_dev_find(net, local.ipv4.s_addr, false); >> @@ -375,7 +375,7 @@ static int tipc_udp_enable(struct net *net, struct >> tipc_bearer *b, >>
Re: [tipc-discussion] [PATCH net-next 3/3] tipc: use sock addr family to indicate IP version
On 06/22/2016 11:40 AM, Erik Hugne wrote: > This change is not backwards compatible, udp_media_addr is carried in the > neighbor discovery messages. > > //E Not sure if backwards compatibility is a big issue at this stage, but as I remember it the 'media_id' field was meant to fulfill this role. ///jon > On Jun 22, 2016 10:03, "Richard Alpe"wrote: > >> Use socket address family instead of ethernet protocol ID to identify >> IP version internally. >> --- >> net/tipc/udp_media.c | 26 +- >> 1 file changed, 13 insertions(+), 13 deletions(-) >> >> diff --git a/net/tipc/udp_media.c b/net/tipc/udp_media.c >> index b016c01..c7df8bd 100644 >> --- a/net/tipc/udp_media.c >> +++ b/net/tipc/udp_media.c >> @@ -62,7 +62,7 @@ >>* messages, and all fields should be in network byte order >>*/ >> struct udp_media_addr { >> - __be16 proto; >> + __kernel_sa_family_t family; >> __be16 port; >> union { >> struct in_addr ipv4; >> @@ -91,10 +91,10 @@ static void tipc_udp_media_addr_set(struct >> tipc_media_addr *addr, >> memset(addr, 0, sizeof(struct tipc_media_addr)); >> addr->media_id = TIPC_MEDIA_TYPE_UDP; >> memcpy(addr->value, ua, sizeof(struct udp_media_addr)); >> - if (ntohs(ua->proto) == ETH_P_IP) { >> + if (ua->family == AF_INET) { >> if (ipv4_is_multicast(ua->ipv4.s_addr)) >> addr->broadcast = 1; >> - } else if (ntohs(ua->proto) == ETH_P_IPV6) { >> + } else if (ua->family == AF_INET6) { >> if (ipv6_addr_type(>ipv6) & IPV6_ADDR_MULTICAST) >> addr->broadcast = 1; >> } else { >> @@ -107,9 +107,9 @@ static int tipc_udp_addr2str(struct tipc_media_addr >> *a, char *buf, int size) >> { >> struct udp_media_addr *ua = (struct udp_media_addr *)>value; >> >> - if (ntohs(ua->proto) == ETH_P_IP) >> + if (ua->family == AF_INET) >> snprintf(buf, size, "%pI4:%u", >ipv4, ntohs(ua->port)); >> - else if (ntohs(ua->proto) == ETH_P_IPV6) >> + else if (ua->family == AF_INET6) >> snprintf(buf, size, "%pI6:%u", >ipv6, ntohs(ua->port)); >> else >> pr_err("Invalid UDP media address\n"); >> @@ -162,7 +162,7 @@ static int tipc_udp_send_msg(struct net *net, struct >> sk_buff *skb, >> err = -ENODEV; >> goto tx_error; >> } >> - if (dst->proto == htons(ETH_P_IP)) { >> + if (dst->family == AF_INET) { >> struct flowi4 fl = { >> .daddr = dst->ipv4.s_addr, >> .saddr = src->ipv4.s_addr, >> @@ -240,7 +240,7 @@ static int enable_mcast(struct udp_bearer *ub, struct >> udp_media_addr *remote) >> struct ip_mreqn mreqn; >> struct sock *sk = ub->ubsock->sk; >> >> - if (ntohs(remote->proto) == ETH_P_IP) { >> + if (remote->family == AF_INET) { >> if (!ipv4_is_multicast(remote->ipv4.s_addr)) >> return 0; >> mreqn.imr_multiaddr = remote->ipv4; >> @@ -291,12 +291,12 @@ err: >> struct sockaddr_in *ip4; >> >> ip4 = (struct sockaddr_in *)_local; >> - local->proto = htons(ETH_P_IP); >> + local->family = AF_INET; >> local->port = ip4->sin_port; >> local->ipv4.s_addr = ip4->sin_addr.s_addr; >> >> ip4 = (struct sockaddr_in *)_remote; >> - remote->proto = htons(ETH_P_IP); >> + remote->family = AF_INET; >> remote->port = ip4->sin_port; >> remote->ipv4.s_addr = ip4->sin_addr.s_addr; >> return 0; >> @@ -311,13 +311,13 @@ err: >> if (__ipv6_addr_needs_scope_id(atype) && >> !ip6->sin6_scope_id) >> return -EINVAL; >> >> - local->proto = htons(ETH_P_IPV6); >> + local->family = AF_INET6; >> local->port = ip6->sin6_port; >> memcpy(>ipv6, >sin6_addr, sizeof(struct >> in6_addr)); >> ub->ifindex = ip6->sin6_scope_id; >> >> ip6 = (struct sockaddr_in6 *)_remote; >> - remote->proto = htons(ETH_P_IPV6); >> + remote->family = htons(ETH_P_IPV6); >> remote->port = ip6->sin6_port; >> memcpy(>ipv6, >sin6_addr, sizeof(struct >> in6_addr)); >> return 0; >> @@ -360,7 +360,7 @@ static int tipc_udp_enable(struct net *net, struct >> tipc_bearer *b, >> rcu_assign_pointer(b->media_ptr, ub); >> rcu_assign_pointer(ub->bearer, b); >> tipc_udp_media_addr_set(>addr, ); >> - if (local.proto == htons(ETH_P_IP)) { >> + if (local.family == AF_INET) { >> struct net_device *dev; >> >>
Re: [tipc-discussion] [PATCH net-next 3/3] tipc: use sock addr family to indicate IP version
This change is not backwards compatible, udp_media_addr is carried in the neighbor discovery messages. //E On Jun 22, 2016 10:03, "Richard Alpe"wrote: > Use socket address family instead of ethernet protocol ID to identify > IP version internally. > --- > net/tipc/udp_media.c | 26 +- > 1 file changed, 13 insertions(+), 13 deletions(-) > > diff --git a/net/tipc/udp_media.c b/net/tipc/udp_media.c > index b016c01..c7df8bd 100644 > --- a/net/tipc/udp_media.c > +++ b/net/tipc/udp_media.c > @@ -62,7 +62,7 @@ > * messages, and all fields should be in network byte order > */ > struct udp_media_addr { > - __be16 proto; > + __kernel_sa_family_t family; > __be16 port; > union { > struct in_addr ipv4; > @@ -91,10 +91,10 @@ static void tipc_udp_media_addr_set(struct > tipc_media_addr *addr, > memset(addr, 0, sizeof(struct tipc_media_addr)); > addr->media_id = TIPC_MEDIA_TYPE_UDP; > memcpy(addr->value, ua, sizeof(struct udp_media_addr)); > - if (ntohs(ua->proto) == ETH_P_IP) { > + if (ua->family == AF_INET) { > if (ipv4_is_multicast(ua->ipv4.s_addr)) > addr->broadcast = 1; > - } else if (ntohs(ua->proto) == ETH_P_IPV6) { > + } else if (ua->family == AF_INET6) { > if (ipv6_addr_type(>ipv6) & IPV6_ADDR_MULTICAST) > addr->broadcast = 1; > } else { > @@ -107,9 +107,9 @@ static int tipc_udp_addr2str(struct tipc_media_addr > *a, char *buf, int size) > { > struct udp_media_addr *ua = (struct udp_media_addr *)>value; > > - if (ntohs(ua->proto) == ETH_P_IP) > + if (ua->family == AF_INET) > snprintf(buf, size, "%pI4:%u", >ipv4, ntohs(ua->port)); > - else if (ntohs(ua->proto) == ETH_P_IPV6) > + else if (ua->family == AF_INET6) > snprintf(buf, size, "%pI6:%u", >ipv6, ntohs(ua->port)); > else > pr_err("Invalid UDP media address\n"); > @@ -162,7 +162,7 @@ static int tipc_udp_send_msg(struct net *net, struct > sk_buff *skb, > err = -ENODEV; > goto tx_error; > } > - if (dst->proto == htons(ETH_P_IP)) { > + if (dst->family == AF_INET) { > struct flowi4 fl = { > .daddr = dst->ipv4.s_addr, > .saddr = src->ipv4.s_addr, > @@ -240,7 +240,7 @@ static int enable_mcast(struct udp_bearer *ub, struct > udp_media_addr *remote) > struct ip_mreqn mreqn; > struct sock *sk = ub->ubsock->sk; > > - if (ntohs(remote->proto) == ETH_P_IP) { > + if (remote->family == AF_INET) { > if (!ipv4_is_multicast(remote->ipv4.s_addr)) > return 0; > mreqn.imr_multiaddr = remote->ipv4; > @@ -291,12 +291,12 @@ err: > struct sockaddr_in *ip4; > > ip4 = (struct sockaddr_in *)_local; > - local->proto = htons(ETH_P_IP); > + local->family = AF_INET; > local->port = ip4->sin_port; > local->ipv4.s_addr = ip4->sin_addr.s_addr; > > ip4 = (struct sockaddr_in *)_remote; > - remote->proto = htons(ETH_P_IP); > + remote->family = AF_INET; > remote->port = ip4->sin_port; > remote->ipv4.s_addr = ip4->sin_addr.s_addr; > return 0; > @@ -311,13 +311,13 @@ err: > if (__ipv6_addr_needs_scope_id(atype) && > !ip6->sin6_scope_id) > return -EINVAL; > > - local->proto = htons(ETH_P_IPV6); > + local->family = AF_INET6; > local->port = ip6->sin6_port; > memcpy(>ipv6, >sin6_addr, sizeof(struct > in6_addr)); > ub->ifindex = ip6->sin6_scope_id; > > ip6 = (struct sockaddr_in6 *)_remote; > - remote->proto = htons(ETH_P_IPV6); > + remote->family = htons(ETH_P_IPV6); > remote->port = ip6->sin6_port; > memcpy(>ipv6, >sin6_addr, sizeof(struct > in6_addr)); > return 0; > @@ -360,7 +360,7 @@ static int tipc_udp_enable(struct net *net, struct > tipc_bearer *b, > rcu_assign_pointer(b->media_ptr, ub); > rcu_assign_pointer(ub->bearer, b); > tipc_udp_media_addr_set(>addr, ); > - if (local.proto == htons(ETH_P_IP)) { > + if (local.family == AF_INET) { > struct net_device *dev; > > dev = __ip_dev_find(net, local.ipv4.s_addr, false); > @@ -375,7 +375,7 @@ static int tipc_udp_enable(struct net *net, struct > tipc_bearer *b, > b->mtu = dev->mtu - sizeof(struct iphdr) > - sizeof(struct udphdr); > #if IS_ENABLED(CONFIG_IPV6) > - } else if (local.proto == htons(ETH_P_IPV6)) { > + } else if