Commit 1281bc25 authored by Paul Moore's avatar Paul Moore Committed by David S. Miller

netlabel: Fix build problems when IPv6 is not enabled

A recent fix to the the NetLabel code caused build problem with
configurations that did not have IPv6 enabled; see below:

 netlabel_kapi.c: In function 'netlbl_cfg_unlbl_map_add':
 netlabel_kapi.c:165:4:
  error: implicit declaration of function 'netlbl_af6list_add'

This patch fixes this problem by making the IPv6 specific code conditional
on the IPv6 configuration flags as we done in the rest of NetLabel and the
network stack as a whole.  We have to move some variable declarations
around as a result so things may not be quite as pretty, but at least it
builds cleanly now.

Some additional IPv6 conditionals were added to the NetLabel code as well
for the sake of consistency.
Reported-by: default avatarRandy Dunlap <rdunlap@xenotime.net>
Signed-off-by: default avatarPaul Moore <pmoore@redhat.com>
Acked-by: default avatarRandy Dunlap <rdunlap@xenotime.net>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent c89304b8
...@@ -111,8 +111,6 @@ int netlbl_cfg_unlbl_map_add(const char *domain, ...@@ -111,8 +111,6 @@ int netlbl_cfg_unlbl_map_add(const char *domain,
struct netlbl_domaddr_map *addrmap = NULL; struct netlbl_domaddr_map *addrmap = NULL;
struct netlbl_domaddr4_map *map4 = NULL; struct netlbl_domaddr4_map *map4 = NULL;
struct netlbl_domaddr6_map *map6 = NULL; struct netlbl_domaddr6_map *map6 = NULL;
const struct in_addr *addr4, *mask4;
const struct in6_addr *addr6, *mask6;
entry = kzalloc(sizeof(*entry), GFP_ATOMIC); entry = kzalloc(sizeof(*entry), GFP_ATOMIC);
if (entry == NULL) if (entry == NULL)
...@@ -133,9 +131,9 @@ int netlbl_cfg_unlbl_map_add(const char *domain, ...@@ -133,9 +131,9 @@ int netlbl_cfg_unlbl_map_add(const char *domain,
INIT_LIST_HEAD(&addrmap->list6); INIT_LIST_HEAD(&addrmap->list6);
switch (family) { switch (family) {
case AF_INET: case AF_INET: {
addr4 = addr; const struct in_addr *addr4 = addr;
mask4 = mask; const struct in_addr *mask4 = mask;
map4 = kzalloc(sizeof(*map4), GFP_ATOMIC); map4 = kzalloc(sizeof(*map4), GFP_ATOMIC);
if (map4 == NULL) if (map4 == NULL)
goto cfg_unlbl_map_add_failure; goto cfg_unlbl_map_add_failure;
...@@ -148,9 +146,11 @@ int netlbl_cfg_unlbl_map_add(const char *domain, ...@@ -148,9 +146,11 @@ int netlbl_cfg_unlbl_map_add(const char *domain,
if (ret_val != 0) if (ret_val != 0)
goto cfg_unlbl_map_add_failure; goto cfg_unlbl_map_add_failure;
break; break;
case AF_INET6: }
addr6 = addr; #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
mask6 = mask; case AF_INET6: {
const struct in6_addr *addr6 = addr;
const struct in6_addr *mask6 = mask;
map6 = kzalloc(sizeof(*map6), GFP_ATOMIC); map6 = kzalloc(sizeof(*map6), GFP_ATOMIC);
if (map6 == NULL) if (map6 == NULL)
goto cfg_unlbl_map_add_failure; goto cfg_unlbl_map_add_failure;
...@@ -167,6 +167,8 @@ int netlbl_cfg_unlbl_map_add(const char *domain, ...@@ -167,6 +167,8 @@ int netlbl_cfg_unlbl_map_add(const char *domain,
if (ret_val != 0) if (ret_val != 0)
goto cfg_unlbl_map_add_failure; goto cfg_unlbl_map_add_failure;
break; break;
}
#endif /* IPv6 */
default: default:
goto cfg_unlbl_map_add_failure; goto cfg_unlbl_map_add_failure;
break; break;
...@@ -225,9 +227,11 @@ int netlbl_cfg_unlbl_static_add(struct net *net, ...@@ -225,9 +227,11 @@ int netlbl_cfg_unlbl_static_add(struct net *net,
case AF_INET: case AF_INET:
addr_len = sizeof(struct in_addr); addr_len = sizeof(struct in_addr);
break; break;
#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
case AF_INET6: case AF_INET6:
addr_len = sizeof(struct in6_addr); addr_len = sizeof(struct in6_addr);
break; break;
#endif /* IPv6 */
default: default:
return -EPFNOSUPPORT; return -EPFNOSUPPORT;
} }
...@@ -266,9 +270,11 @@ int netlbl_cfg_unlbl_static_del(struct net *net, ...@@ -266,9 +270,11 @@ int netlbl_cfg_unlbl_static_del(struct net *net,
case AF_INET: case AF_INET:
addr_len = sizeof(struct in_addr); addr_len = sizeof(struct in_addr);
break; break;
#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
case AF_INET6: case AF_INET6:
addr_len = sizeof(struct in6_addr); addr_len = sizeof(struct in6_addr);
break; break;
#endif /* IPv6 */
default: default:
return -EPFNOSUPPORT; return -EPFNOSUPPORT;
} }
......
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