diff options
author | Ido Schimmel <idosch@mellanox.com> | 2018-10-17 04:53:10 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2018-10-17 20:45:07 -0400 |
commit | cca45e054ce55c06046a37bf4d3fd7c17edd57da (patch) | |
tree | 613005c07e9fbaac55946ebc6063024c5dc1bc52 /include/net/vxlan.h | |
parent | 88782f75f93f62928c26d7e7e5c1649f85dd1469 (diff) |
vxlan: Export address checking functions
Drivers that support VxLAN offload need to be able to sanitize the
configuration of the VxLAN device and accept / reject its offload.
For example, mlxsw requires that the local IP of the VxLAN device be set
and that packets be flooded to unicast IP(s) and not to a multicast
group.
Expose the functions that perform such checks.
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Reviewed-by: Petr Machata <petrm@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/net/vxlan.h')
-rw-r--r-- | include/net/vxlan.h | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/include/net/vxlan.h b/include/net/vxlan.h index 7ef15179f263..dd3d72ce64b6 100644 --- a/include/net/vxlan.h +++ b/include/net/vxlan.h | |||
@@ -370,4 +370,36 @@ static inline unsigned short vxlan_get_sk_family(struct vxlan_sock *vs) | |||
370 | return vs->sock->sk->sk_family; | 370 | return vs->sock->sk->sk_family; |
371 | } | 371 | } |
372 | 372 | ||
373 | #if IS_ENABLED(CONFIG_IPV6) | ||
374 | |||
375 | static inline bool vxlan_addr_any(const union vxlan_addr *ipa) | ||
376 | { | ||
377 | if (ipa->sa.sa_family == AF_INET6) | ||
378 | return ipv6_addr_any(&ipa->sin6.sin6_addr); | ||
379 | else | ||
380 | return ipa->sin.sin_addr.s_addr == htonl(INADDR_ANY); | ||
381 | } | ||
382 | |||
383 | static inline bool vxlan_addr_multicast(const union vxlan_addr *ipa) | ||
384 | { | ||
385 | if (ipa->sa.sa_family == AF_INET6) | ||
386 | return ipv6_addr_is_multicast(&ipa->sin6.sin6_addr); | ||
387 | else | ||
388 | return IN_MULTICAST(ntohl(ipa->sin.sin_addr.s_addr)); | ||
389 | } | ||
390 | |||
391 | #else /* !IS_ENABLED(CONFIG_IPV6) */ | ||
392 | |||
393 | static inline bool vxlan_addr_any(const union vxlan_addr *ipa) | ||
394 | { | ||
395 | return ipa->sin.sin_addr.s_addr == htonl(INADDR_ANY); | ||
396 | } | ||
397 | |||
398 | static inline bool vxlan_addr_multicast(const union vxlan_addr *ipa) | ||
399 | { | ||
400 | return IN_MULTICAST(ntohl(ipa->sin.sin_addr.s_addr)); | ||
401 | } | ||
402 | |||
403 | #endif /* IS_ENABLED(CONFIG_IPV6) */ | ||
404 | |||
373 | #endif | 405 | #endif |