]> git.puffer.fish Git - matthieu/frr.git/commitdiff
lib: Allow using IPv4 (Class E) reserved block if enabled
authorDonatas Abraitis <donatas@opensourcerouting.org>
Fri, 1 Jul 2022 20:26:24 +0000 (23:26 +0300)
committerDonatas Abraitis <donatas@opensourcerouting.org>
Fri, 1 Jul 2022 20:38:13 +0000 (23:38 +0300)
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
lib/prefix.c
lib/prefix.h

index 1a3efd32b19e6e28829aa511eca2a50c063e0e8e..e64b10bf24787452081c01262c3ff839b0a632ed 100644 (file)
@@ -21,6 +21,7 @@
 
 #include <zebra.h>
 
+#include "command.h"
 #include "prefix.h"
 #include "ipaddr.h"
 #include "vty.h"
@@ -1386,6 +1387,23 @@ char *evpn_es_df_alg2str(uint8_t df_alg, char *buf, int buf_len)
        return buf;
 }
 
+bool ipv4_unicast_valid(const struct in_addr *addr)
+{
+       in_addr_t ip = ntohl(addr->s_addr);
+
+       if (IPV4_CLASS_D(ip))
+               return false;
+
+       if (IPV4_CLASS_E(ip)) {
+               if (cmd_allow_reserved_ranges_get())
+                       return true;
+               else
+                       return false;
+       }
+
+       return true;
+}
+
 printfrr_ext_autoreg_p("EA", printfrr_ea);
 static ssize_t printfrr_ea(struct fbuf *buf, struct printfrr_eargs *ea,
                           const void *ptr)
index f9eef28a0bb429e63d397916b454e2bd4d5b8c5c..6c51186f52aff9455a583b3657ea1ffbd72dd33f 100644 (file)
@@ -382,6 +382,8 @@ static inline void ipv4_addr_copy(struct in_addr *dst,
 #define IPV4_NET0(a) ((((uint32_t)(a)) & 0xff000000) == 0x00000000)
 #define IPV4_NET127(a) ((((uint32_t)(a)) & 0xff000000) == 0x7f000000)
 #define IPV4_LINKLOCAL(a) ((((uint32_t)(a)) & 0xffff0000) == 0xa9fe0000)
+#define IPV4_CLASS_D(a) ((((uint32_t)(a)) & 0xf0000000) == 0xe0000000)
+#define IPV4_CLASS_E(a) ((((uint32_t)(a)) & 0xf0000000) == 0xf0000000)
 #define IPV4_CLASS_DE(a) ((((uint32_t)(a)) & 0xe0000000) == 0xe0000000)
 #define IPV4_MC_LINKLOCAL(a) ((((uint32_t)(a)) & 0xffffff00) == 0xe0000000)
 
@@ -507,17 +509,7 @@ extern int str_to_esi(const char *str, esi_t *esi);
 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;
-}
+extern bool ipv4_unicast_valid(const struct in_addr *addr);
 
 static inline int ipv6_martian(const struct in6_addr *addr)
 {