diff options
author | Donatas Abraitis <donatas@opensourcerouting.org> | 2022-06-06 09:47:27 +0200 |
---|---|---|
committer | Donatas Abraitis <donatas@opensourcerouting.org> | 2022-06-13 19:44:52 +0200 |
commit | e24a6977ee763f58e922ad2728882a9a70027f33 (patch) | |
tree | fc4a08b59f9b537f6f6f0026619883e1901e7e84 /lib/prefix.h | |
parent | Merge pull request #11333 from opensourcerouting/fix/memory_leak_with_rmaps (diff) | |
download | frr-e24a6977ee763f58e922ad2728882a9a70027f33.tar.xz frr-e24a6977ee763f58e922ad2728882a9a70027f33.zip |
bgpd: Wrap IPV4_CLASS_DE into ipv4_unicast_valid() helper
Linux kernel allows (FreeBSD/OpenBSD too) using reserved class E IP ranges.
This is a preparation commit that ease the global switch to allow/deny
class E IP ranges in FRR.
https://datatracker.ietf.org/doc/html/draft-chen-ati-adaptive-ipv4-address-space
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
Diffstat (limited to 'lib/prefix.h')
-rw-r--r-- | lib/prefix.h | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/prefix.h b/lib/prefix.h index e043d41d3..42394ec61 100644 --- a/lib/prefix.h +++ b/lib/prefix.h @@ -508,6 +508,17 @@ extern char *esi_to_str(const esi_t *esi, char *buf, int size); extern char *evpn_es_df_alg2str(uint8_t df_alg, char *buf, int buf_len); extern void prefix_evpn_hexdump(const struct prefix_evpn *p); +static inline bool ipv4_unicast_valid(const struct in_addr *addr) +{ + + in_addr_t ip = ntohl(addr->s_addr); + + if (IPV4_CLASS_DE(ip)) + return false; + + return true; +} + static inline int ipv6_martian(const struct in6_addr *addr) { struct in6_addr localhost_addr; @@ -527,7 +538,7 @@ static inline int ipv4_martian(const struct in_addr *addr) { in_addr_t ip = ntohl(addr->s_addr); - if (IPV4_NET0(ip) || IPV4_NET127(ip) || IPV4_CLASS_DE(ip)) { + if (IPV4_NET0(ip) || IPV4_NET127(ip) || !ipv4_unicast_valid(addr)) { return 1; } return 0; |