diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/prefix.h | 13 | ||||
| -rw-r--r-- | lib/routemap_northbound.c | 2 |
2 files changed, 13 insertions, 2 deletions
diff --git a/lib/prefix.h b/lib/prefix.h index e043d41d30..42394ec61c 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; diff --git a/lib/routemap_northbound.c b/lib/routemap_northbound.c index 51b879959f..0ccfe98af0 100644 --- a/lib/routemap_northbound.c +++ b/lib/routemap_northbound.c @@ -887,7 +887,7 @@ static int lib_route_map_entry_set_action_ipv4_address_modify( * only implemented action. */ yang_dnode_get_ipv4(&ia, args->dnode, NULL); - if (ia.s_addr == INADDR_ANY || IPV4_CLASS_DE(ntohl(ia.s_addr))) + if (ia.s_addr == INADDR_ANY || !ipv4_unicast_valid(&ia)) return NB_ERR_VALIDATION; /* FALLTHROUGH */ case NB_EV_PREPARE: |
