/* Check if received nexthop is valid or not. */
static int bgp_update_martian_nexthop(struct bgp *bgp, afi_t afi, safi_t safi,
- struct attr *attr)
+ uint8_t type, uint8_t stype,
+ struct attr *attr, struct bgp_node *rn)
{
int ret = 0;
if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_NEXT_HOP)) {
if (attr->nexthop.s_addr == 0
|| IPV4_CLASS_DE(ntohl(attr->nexthop.s_addr))
- || bgp_nexthop_self(bgp, attr->nexthop))
+ || bgp_nexthop_self(bgp, afi, type, stype,
+ attr, rn))
return 1;
}
ret = (attr->mp_nexthop_global_in.s_addr == 0
|| IPV4_CLASS_DE(ntohl(
attr->mp_nexthop_global_in.s_addr))
- || bgp_nexthop_self(bgp,
- attr->mp_nexthop_global_in));
+ || bgp_nexthop_self(bgp, afi, type, stype,
+ attr, rn));
break;
case BGP_ATTR_NHLEN_IPV6_GLOBAL:
ret = (IN6_IS_ADDR_UNSPECIFIED(&attr->mp_nexthop_global)
|| IN6_IS_ADDR_LOOPBACK(&attr->mp_nexthop_global)
|| IN6_IS_ADDR_MULTICAST(
- &attr->mp_nexthop_global));
+ &attr->mp_nexthop_global)
+ || bgp_nexthop_self(bgp, afi, type, stype,
+ attr, rn));
break;
default:
int do_loop_check = 1;
int has_valid_label = 0;
afi_t nh_afi;
+ uint8_t pi_type = 0;
+ uint8_t pi_sub_type = 0;
+
#if ENABLE_BGP_VNC
int vnc_implicit_withdraw = 0;
#endif
}
}
+ if (pi) {
+ pi_type = pi->type;
+ pi_sub_type = pi->sub_type;
+ }
+
/* next hop check. */
if (!CHECK_FLAG(peer->flags, PEER_FLAG_IS_RFAPI_HD)
- && bgp_update_martian_nexthop(bgp, afi, safi, &new_attr)) {
+ && bgp_update_martian_nexthop(bgp, afi, safi, pi_type,
+ pi_sub_type, &new_attr, rn)) {
peer->stat_pfx_nh_invalid++;
reason = "martian or self next-hop;";
bgp_attr_flush(&new_attr);