Commit d1912747 authored by David Howells's avatar David Howells Committed by David S. Miller

rxrpc: Make IPv6 support conditional on CONFIG_IPV6

Add CONFIG_AF_RXRPC_IPV6 and make the IPv6 support code conditional on it.
This is then made conditional on CONFIG_IPV6.

Without this, the following can be seen:

   net/built-in.o: In function `rxrpc_init_peer':
>> peer_object.c:(.text+0x18c3c8): undefined reference to `ip6_route_output_flags'
Reported-by: default avatarkbuild test robot <fengguang.wu@intel.com>
Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 84ce3da1
...@@ -19,6 +19,13 @@ config AF_RXRPC ...@@ -19,6 +19,13 @@ config AF_RXRPC
See Documentation/networking/rxrpc.txt. See Documentation/networking/rxrpc.txt.
config AF_RXRPC_IPV6
bool "IPv6 support for RxRPC"
depends on (IPV6 = m && AF_RXRPC = m) || (IPV6 = y && AF_RXRPC)
help
Say Y here to allow AF_RXRPC to use IPV6 UDP as well as IPV4 UDP as
its network transport.
config AF_RXRPC_DEBUG config AF_RXRPC_DEBUG
bool "RxRPC dynamic debugging" bool "RxRPC dynamic debugging"
......
...@@ -109,12 +109,14 @@ static int rxrpc_validate_address(struct rxrpc_sock *rx, ...@@ -109,12 +109,14 @@ static int rxrpc_validate_address(struct rxrpc_sock *rx,
tail = offsetof(struct sockaddr_rxrpc, transport.sin.__pad); tail = offsetof(struct sockaddr_rxrpc, transport.sin.__pad);
break; break;
#ifdef CONFIG_AF_RXRPC_IPV6
case AF_INET6: case AF_INET6:
if (srx->transport_len < sizeof(struct sockaddr_in6)) if (srx->transport_len < sizeof(struct sockaddr_in6))
return -EINVAL; return -EINVAL;
tail = offsetof(struct sockaddr_rxrpc, transport) + tail = offsetof(struct sockaddr_rxrpc, transport) +
sizeof(struct sockaddr_in6); sizeof(struct sockaddr_in6);
break; break;
#endif
default: default:
return -EAFNOSUPPORT; return -EAFNOSUPPORT;
...@@ -413,9 +415,11 @@ static int rxrpc_sendmsg(struct socket *sock, struct msghdr *m, size_t len) ...@@ -413,9 +415,11 @@ static int rxrpc_sendmsg(struct socket *sock, struct msghdr *m, size_t len)
case AF_INET: case AF_INET:
rx->srx.transport_len = sizeof(struct sockaddr_in); rx->srx.transport_len = sizeof(struct sockaddr_in);
break; break;
#ifdef CONFIG_AF_RXRPC_IPV6
case AF_INET6: case AF_INET6:
rx->srx.transport_len = sizeof(struct sockaddr_in6); rx->srx.transport_len = sizeof(struct sockaddr_in6);
break; break;
#endif
default: default:
ret = -EAFNOSUPPORT; ret = -EAFNOSUPPORT;
goto error_unlock; goto error_unlock;
...@@ -570,7 +574,8 @@ static int rxrpc_create(struct net *net, struct socket *sock, int protocol, ...@@ -570,7 +574,8 @@ static int rxrpc_create(struct net *net, struct socket *sock, int protocol,
return -EAFNOSUPPORT; return -EAFNOSUPPORT;
/* we support transport protocol UDP/UDP6 only */ /* we support transport protocol UDP/UDP6 only */
if (protocol != PF_INET && protocol != PF_INET6) if (protocol != PF_INET &&
IS_ENABLED(CONFIG_AF_RXRPC_IPV6) && protocol != PF_INET6)
return -EPROTONOSUPPORT; return -EPROTONOSUPPORT;
if (sock->type != SOCK_DGRAM) if (sock->type != SOCK_DGRAM)
......
...@@ -134,6 +134,7 @@ struct rxrpc_connection *rxrpc_find_connection_rcu(struct rxrpc_local *local, ...@@ -134,6 +134,7 @@ struct rxrpc_connection *rxrpc_find_connection_rcu(struct rxrpc_local *local,
srx.transport.sin.sin_addr.s_addr) srx.transport.sin.sin_addr.s_addr)
goto not_found; goto not_found;
break; break;
#ifdef CONFIG_AF_RXRPC_IPV6
case AF_INET6: case AF_INET6:
if (peer->srx.transport.sin6.sin6_port != if (peer->srx.transport.sin6.sin6_port !=
srx.transport.sin6.sin6_port || srx.transport.sin6.sin6_port ||
...@@ -142,6 +143,7 @@ struct rxrpc_connection *rxrpc_find_connection_rcu(struct rxrpc_local *local, ...@@ -142,6 +143,7 @@ struct rxrpc_connection *rxrpc_find_connection_rcu(struct rxrpc_local *local,
sizeof(struct in6_addr)) != 0) sizeof(struct in6_addr)) != 0)
goto not_found; goto not_found;
break; break;
#endif
default: default:
BUG(); BUG();
} }
......
...@@ -58,6 +58,7 @@ static long rxrpc_local_cmp_key(const struct rxrpc_local *local, ...@@ -58,6 +58,7 @@ static long rxrpc_local_cmp_key(const struct rxrpc_local *local,
memcmp(&local->srx.transport.sin.sin_addr, memcmp(&local->srx.transport.sin.sin_addr,
&srx->transport.sin.sin_addr, &srx->transport.sin.sin_addr,
sizeof(struct in_addr)); sizeof(struct in_addr));
#ifdef CONFIG_AF_RXRPC_IPV6
case AF_INET6: case AF_INET6:
/* If the choice of UDP6 port is left up to the transport, then /* If the choice of UDP6 port is left up to the transport, then
* the endpoint record doesn't match. * the endpoint record doesn't match.
...@@ -67,6 +68,7 @@ static long rxrpc_local_cmp_key(const struct rxrpc_local *local, ...@@ -67,6 +68,7 @@ static long rxrpc_local_cmp_key(const struct rxrpc_local *local,
memcmp(&local->srx.transport.sin6.sin6_addr, memcmp(&local->srx.transport.sin6.sin6_addr,
&srx->transport.sin6.sin6_addr, &srx->transport.sin6.sin6_addr,
sizeof(struct in6_addr)); sizeof(struct in6_addr));
#endif
default: default:
BUG(); BUG();
} }
......
...@@ -259,6 +259,7 @@ int rxrpc_send_data_packet(struct rxrpc_connection *conn, struct sk_buff *skb) ...@@ -259,6 +259,7 @@ int rxrpc_send_data_packet(struct rxrpc_connection *conn, struct sk_buff *skb)
} }
break; break;
#ifdef CONFIG_AF_RXRPC_IPV6
case AF_INET6: case AF_INET6:
opt = IPV6_PMTUDISC_DONT; opt = IPV6_PMTUDISC_DONT;
ret = kernel_setsockopt(conn->params.local->socket, ret = kernel_setsockopt(conn->params.local->socket,
...@@ -274,6 +275,7 @@ int rxrpc_send_data_packet(struct rxrpc_connection *conn, struct sk_buff *skb) ...@@ -274,6 +275,7 @@ int rxrpc_send_data_packet(struct rxrpc_connection *conn, struct sk_buff *skb)
(char *)&opt, sizeof(opt)); (char *)&opt, sizeof(opt));
} }
break; break;
#endif
} }
up_write(&conn->params.local->defrag_sem); up_write(&conn->params.local->defrag_sem);
......
...@@ -66,6 +66,7 @@ static struct rxrpc_peer *rxrpc_lookup_peer_icmp_rcu(struct rxrpc_local *local, ...@@ -66,6 +66,7 @@ static struct rxrpc_peer *rxrpc_lookup_peer_icmp_rcu(struct rxrpc_local *local,
} }
break; break;
#ifdef CONFIG_AF_RXRPC_IPV6
case AF_INET6: case AF_INET6:
srx.transport.sin6.sin6_port = serr->port; srx.transport.sin6.sin6_port = serr->port;
srx.transport_len = sizeof(struct sockaddr_in6); srx.transport_len = sizeof(struct sockaddr_in6);
...@@ -78,7 +79,7 @@ static struct rxrpc_peer *rxrpc_lookup_peer_icmp_rcu(struct rxrpc_local *local, ...@@ -78,7 +79,7 @@ static struct rxrpc_peer *rxrpc_lookup_peer_icmp_rcu(struct rxrpc_local *local,
break; break;
case SO_EE_ORIGIN_ICMP: case SO_EE_ORIGIN_ICMP:
_net("Rx ICMP on v6 sock"); _net("Rx ICMP on v6 sock");
memcpy(&srx.transport.sin6.sin6_addr.s6_addr + 12, memcpy(srx.transport.sin6.sin6_addr.s6_addr + 12,
skb_network_header(skb) + serr->addr_offset, skb_network_header(skb) + serr->addr_offset,
sizeof(struct in_addr)); sizeof(struct in_addr));
break; break;
...@@ -89,6 +90,7 @@ static struct rxrpc_peer *rxrpc_lookup_peer_icmp_rcu(struct rxrpc_local *local, ...@@ -89,6 +90,7 @@ static struct rxrpc_peer *rxrpc_lookup_peer_icmp_rcu(struct rxrpc_local *local,
break; break;
} }
break; break;
#endif
default: default:
BUG(); BUG();
......
...@@ -52,11 +52,13 @@ static unsigned long rxrpc_peer_hash_key(struct rxrpc_local *local, ...@@ -52,11 +52,13 @@ static unsigned long rxrpc_peer_hash_key(struct rxrpc_local *local,
size = sizeof(srx->transport.sin.sin_addr); size = sizeof(srx->transport.sin.sin_addr);
p = (u16 *)&srx->transport.sin.sin_addr; p = (u16 *)&srx->transport.sin.sin_addr;
break; break;
#ifdef CONFIG_AF_RXRPC_IPV6
case AF_INET6: case AF_INET6:
hash_key += (u16 __force)srx->transport.sin.sin_port; hash_key += (u16 __force)srx->transport.sin.sin_port;
size = sizeof(srx->transport.sin6.sin6_addr); size = sizeof(srx->transport.sin6.sin6_addr);
p = (u16 *)&srx->transport.sin6.sin6_addr; p = (u16 *)&srx->transport.sin6.sin6_addr;
break; break;
#endif
default: default:
WARN(1, "AF_RXRPC: Unsupported transport address family\n"); WARN(1, "AF_RXRPC: Unsupported transport address family\n");
return 0; return 0;
...@@ -100,12 +102,14 @@ static long rxrpc_peer_cmp_key(const struct rxrpc_peer *peer, ...@@ -100,12 +102,14 @@ static long rxrpc_peer_cmp_key(const struct rxrpc_peer *peer,
memcmp(&peer->srx.transport.sin.sin_addr, memcmp(&peer->srx.transport.sin.sin_addr,
&srx->transport.sin.sin_addr, &srx->transport.sin.sin_addr,
sizeof(struct in_addr)); sizeof(struct in_addr));
#ifdef CONFIG_AF_RXRPC_IPV6
case AF_INET6: case AF_INET6:
return ((u16 __force)peer->srx.transport.sin6.sin6_port - return ((u16 __force)peer->srx.transport.sin6.sin6_port -
(u16 __force)srx->transport.sin6.sin6_port) ?: (u16 __force)srx->transport.sin6.sin6_port) ?:
memcmp(&peer->srx.transport.sin6.sin6_addr, memcmp(&peer->srx.transport.sin6.sin6_addr,
&srx->transport.sin6.sin6_addr, &srx->transport.sin6.sin6_addr,
sizeof(struct in6_addr)); sizeof(struct in6_addr));
#endif
default: default:
BUG(); BUG();
} }
...@@ -159,7 +163,9 @@ static void rxrpc_assess_MTU_size(struct rxrpc_peer *peer) ...@@ -159,7 +163,9 @@ static void rxrpc_assess_MTU_size(struct rxrpc_peer *peer)
struct rtable *rt; struct rtable *rt;
struct flowi fl; struct flowi fl;
struct flowi4 *fl4 = &fl.u.ip4; struct flowi4 *fl4 = &fl.u.ip4;
#ifdef CONFIG_AF_RXRPC_IPV6
struct flowi6 *fl6 = &fl.u.ip6; struct flowi6 *fl6 = &fl.u.ip6;
#endif
peer->if_mtu = 1500; peer->if_mtu = 1500;
...@@ -177,6 +183,7 @@ static void rxrpc_assess_MTU_size(struct rxrpc_peer *peer) ...@@ -177,6 +183,7 @@ static void rxrpc_assess_MTU_size(struct rxrpc_peer *peer)
dst = &rt->dst; dst = &rt->dst;
break; break;
#ifdef CONFIG_AF_RXRPC_IPV6
case AF_INET6: case AF_INET6:
fl6->flowi6_iif = LOOPBACK_IFINDEX; fl6->flowi6_iif = LOOPBACK_IFINDEX;
fl6->flowi6_scope = RT_SCOPE_UNIVERSE; fl6->flowi6_scope = RT_SCOPE_UNIVERSE;
...@@ -191,6 +198,7 @@ static void rxrpc_assess_MTU_size(struct rxrpc_peer *peer) ...@@ -191,6 +198,7 @@ static void rxrpc_assess_MTU_size(struct rxrpc_peer *peer)
return; return;
} }
break; break;
#endif
default: default:
BUG(); BUG();
...@@ -241,9 +249,11 @@ static void rxrpc_init_peer(struct rxrpc_peer *peer, unsigned long hash_key) ...@@ -241,9 +249,11 @@ static void rxrpc_init_peer(struct rxrpc_peer *peer, unsigned long hash_key)
case AF_INET: case AF_INET:
peer->hdrsize = sizeof(struct iphdr); peer->hdrsize = sizeof(struct iphdr);
break; break;
#ifdef CONFIG_AF_RXRPC_IPV6
case AF_INET6: case AF_INET6:
peer->hdrsize = sizeof(struct ipv6hdr); peer->hdrsize = sizeof(struct ipv6hdr);
break; break;
#endif
default: default:
BUG(); BUG();
} }
......
...@@ -30,6 +30,7 @@ int rxrpc_extract_addr_from_skb(struct sockaddr_rxrpc *srx, struct sk_buff *skb) ...@@ -30,6 +30,7 @@ int rxrpc_extract_addr_from_skb(struct sockaddr_rxrpc *srx, struct sk_buff *skb)
srx->transport.sin.sin_addr.s_addr = ip_hdr(skb)->saddr; srx->transport.sin.sin_addr.s_addr = ip_hdr(skb)->saddr;
return 0; return 0;
#ifdef CONFIG_AF_RXRPC_IPV6
case ETH_P_IPV6: case ETH_P_IPV6:
srx->transport_type = SOCK_DGRAM; srx->transport_type = SOCK_DGRAM;
srx->transport_len = sizeof(srx->transport.sin6); srx->transport_len = sizeof(srx->transport.sin6);
...@@ -37,6 +38,7 @@ int rxrpc_extract_addr_from_skb(struct sockaddr_rxrpc *srx, struct sk_buff *skb) ...@@ -37,6 +38,7 @@ int rxrpc_extract_addr_from_skb(struct sockaddr_rxrpc *srx, struct sk_buff *skb)
srx->transport.sin6.sin6_port = udp_hdr(skb)->source; srx->transport.sin6.sin6_port = udp_hdr(skb)->source;
srx->transport.sin6.sin6_addr = ipv6_hdr(skb)->saddr; srx->transport.sin6.sin6_addr = ipv6_hdr(skb)->saddr;
return 0; return 0;
#endif
default: default:
pr_warn_ratelimited("AF_RXRPC: Unknown eth protocol %u\n", pr_warn_ratelimited("AF_RXRPC: Unknown eth protocol %u\n",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment