stream_getl(s); /* RD low */
}
stream_get(&attr->mp_nexthop_global, s, IPV6_MAX_BYTELEN);
- if (IN6_IS_ADDR_LINKLOCAL(&attr->mp_nexthop_global))
+ if (IN6_IS_ADDR_LINKLOCAL(&attr->mp_nexthop_global)) {
+ if (!peer->nexthop.ifp) {
+ zlog_warn("%s: interface not set appropriately to handle some attributes",
+ peer->host);
+ return BGP_ATTR_PARSE_WITHDRAW;
+ }
attr->nh_ifindex = peer->nexthop.ifp->ifindex;
+ }
break;
case BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL:
case BGP_ATTR_NHLEN_VPNV6_GLOBAL_AND_LL:
stream_getl(s); /* RD low */
}
stream_get(&attr->mp_nexthop_global, s, IPV6_MAX_BYTELEN);
- if (IN6_IS_ADDR_LINKLOCAL(&attr->mp_nexthop_global))
+ if (IN6_IS_ADDR_LINKLOCAL(&attr->mp_nexthop_global)) {
+ if (!peer->nexthop.ifp) {
+ zlog_warn("%s: interface not set appropriately to handle some attributes",
+ peer->host);
+ return BGP_ATTR_PARSE_WITHDRAW;
+ }
attr->nh_ifindex = peer->nexthop.ifp->ifindex;
+ }
if (attr->mp_nexthop_len
== BGP_ATTR_NHLEN_VPNV6_GLOBAL_AND_LL) {
stream_getl(s); /* RD high */
attr->mp_nexthop_len = IPV6_MAX_BYTELEN;
}
+ if (!peer->nexthop.ifp) {
+ zlog_warn("%s: Interface not set appropriately to handle this some attributes",
+ peer->host);
+ return BGP_ATTR_PARSE_WITHDRAW;
+ }
attr->nh_lla_ifindex = peer->nexthop.ifp->ifindex;
break;
default:
#include "filter.h"
#include "ns.h"
#include "lib_errors.h"
+#include "nexthop.h"
#include "bgpd/bgpd.h"
#include "bgpd/bgp_open.h"
#include "bgpd/bgp_debug.h"
#include "bgpd/bgp_errors.h"
#include "bgpd/bgp_network.h"
+#include "bgpd/bgp_zebra.h"
extern struct zebra_privs_t bgpd_privs;
if (!peer->su_remote)
return -1;
- if (bgp_nexthop_set(peer->su_local, peer->su_remote, &peer->nexthop,
- peer)) {
-#if defined(HAVE_CUMULUS)
- flog_err(
- BGP_ERR_NH_UPD,
- "%s: nexthop_set failed, resetting connection - intf %p",
- peer->host, peer->nexthop.ifp);
+ if (!bgp_zebra_nexthop_set(peer->su_local, peer->su_remote,
+ &peer->nexthop, peer)) {
+ flog_err(BGP_ERR_NH_UPD,
+ "%s: nexthop_set failed, resetting connection - intf %p",
+ peer->host, peer->nexthop.ifp);
return -1;
-#endif
}
return 0;
}
return 0;
}
-int bgp_nexthop_set(union sockunion *local, union sockunion *remote,
- struct bgp_nexthop *nexthop, struct peer *peer)
+
+bool bgp_zebra_nexthop_set(union sockunion *local, union sockunion *remote,
+ struct bgp_nexthop *nexthop, struct peer *peer)
{
int ret = 0;
struct interface *ifp = NULL;
memset(nexthop, 0, sizeof(struct bgp_nexthop));
if (!local)
- return -1;
+ return false;
if (!remote)
- return -1;
+ return false;
if (local->sa.sa_family == AF_INET) {
nexthop->v4 = local->sin.sin_addr;
peer->bgp->vrf_id);
}
- if (!ifp)
- return -1;
+ if (!ifp) {
+ /*
+ * BGP views do not currently get proper data
+ * from zebra( when attached ) to be able to
+ * properly resolve nexthops, so give this
+ * instance type a pass.
+ */
+ if (peer->bgp->inst_type == BGP_INSTANCE_TYPE_VIEW)
+ return true;
+ /*
+ * If we have no interface data but we have established
+ * some connection w/ zebra than something has gone
+ * terribly terribly wrong here, so say this failed
+ * If we do not any zebra connection then not
+ * having a ifp pointer is ok.
+ */
+ return zclient_num_connects ? false : true;
+ }
nexthop->ifp = ifp;
/* If we have identified the local interface, there is no error for now.
*/
- return 0;
+ return true;
}
static struct in6_addr *bgp_info_to_ipv6_nexthop(struct bgp_info *info,
extern int bgp_zebra_num_connects(void);
+extern bool bgp_zebra_nexthop_set(union sockunion *, union sockunion *,
+ struct bgp_nexthop *, struct peer *);
+
struct bgp_pbr_action;
struct bgp_pbr_match;
struct bgp_pbr_match_entry;
extern void bgp_reset(void);
extern time_t bgp_clock(void);
extern void bgp_zclient_reset(void);
-extern int bgp_nexthop_set(union sockunion *, union sockunion *,
- struct bgp_nexthop *, struct peer *);
extern struct bgp *bgp_get_default(void);
extern struct bgp *bgp_lookup(as_t, const char *);
extern struct bgp *bgp_lookup_by_name(const char *);