Commit 3d23e41d authored by Ondrej Zajicek (work)'s avatar Ondrej Zajicek (work)
Browse files

Nest: Use rtable for neighbor lookup

Implicitly define rtables 'local4' and 'local6' and a pair of direct
protocols to fill them. Use modified net_route() for neighbor
lookup to avoid iterating over all interfaces.
parent 7d1c2ea5
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -30,6 +30,8 @@ struct config {
  char *syslog_name;			/* Name used for syslog (NULL -> no syslog) */
  struct rtable_config *def_tables[NET_MAX]; /* Default routing tables for each network */
  struct iface_patt *router_id_from;	/* Configured list of router ID iface patterns */
  struct rtable_config *local4;
  struct rtable_config *local6;

  u32 router_id;			/* Our Router ID */
  unsigned proto_default_debug;		/* Default protocol debug mask */
+1 −1
Original line number Diff line number Diff line
@@ -74,7 +74,7 @@ CF_KEYWORDS(PRIMARY, STATS, COUNT, BY, FOR, COMMANDS, PREEXPORT, NOEXPORT, GENER
CF_KEYWORDS(BGP, PASSWORDS, DESCRIPTION, SORTED, ORDERED)
CF_KEYWORDS(RELOAD, IN, OUT, MRTDUMP, MESSAGES, RESTRICT, MEMORY, IGP_METRIC, CLASS, DSCP)
CF_KEYWORDS(TIMEFORMAT, ISO, SHORT, LONG, ROUTE, PROTOCOL, BASE, LOG, S, MS, US)
CF_KEYWORDS(GRACEFUL, RESTART, WAIT, MAX, FLUSH, AS, STATISTICS)
CF_KEYWORDS(GRACEFUL, RESTART, WAIT, MAX, FLUSH, AS, STATISTICS, NETWORKS, ADDRESSES)

/* For r_args_channel */
CF_KEYWORDS(IPV4, IPV4_MC, IPV4_MPLS, IPV6, IPV6_MC, IPV6_MPLS, IPV6_SADR, VPN4, VPN4_MC, VPN4_MPLS, VPN6, VPN6_MC, VPN6_MPLS, ROA4, ROA6, FLOW4, FLOW6, MPLS, PRI, SEC)
+6 −6
Original line number Diff line number Diff line
@@ -122,6 +122,8 @@ neigh_find(struct proto *p, ip_addr *a, unsigned flags)
  return neigh_find2(p, a, NULL, flags);
}

struct iface * net_route_ifa(const ip_addr *a, struct iface *vrf);


neighbor *
neigh_find2(struct proto *p, ip_addr *a, struct iface *ifa, unsigned flags)
@@ -153,12 +155,10 @@ neigh_find2(struct proto *p, ip_addr *a, struct iface *ifa, unsigned flags)
	scope = class & IADDR_SCOPE_MASK;
    }
  else
    WALK_LIST(i, iface_list)
      if ((!p->vrf || p->vrf == i->master) &&
	  ((scope = if_connected(a, i, &addr)) >= 0))
    {
      if ((i = net_route_ifa(a, p->vrf)) &&
	  ((scope = if_connected(a, i, &addr)) >= 0))
	ifa = i;
	  break;
    }

  /* scope < 0 means i don't know neighbor */
+10 −3
Original line number Diff line number Diff line
@@ -737,6 +737,7 @@ proto_new(struct proto_config *cf)
  p->proto = cf->protocol;
  p->net_type = cf->net_type;
  p->disabled = cf->disabled;
  p->hidden = cf->hidden;
  p->hash_key = random_u32();
  cf->proto = p;

@@ -1025,7 +1026,13 @@ protos_commit(struct config *new, struct config *old, int force_reconfig, int ty

  DBG("Protocol start\n");

  /* Start device protocol first */

  /* Start direct protocols first */
  WALK_LIST_DELSAFE(p, n, proto_list)
    if (p->proto == &proto_device)
      proto_rethink_goal(p);

  /* Start device protocol second */
  if (first_dev_proto)
    proto_rethink_goal(first_dev_proto);

@@ -1903,7 +1910,7 @@ proto_apply_cmd_patt(char *patt, void (* cmd)(struct proto *, uintptr_t, int), u
  int cnt = 0;

  WALK_LIST(p, proto_list)
    if (!patt || patmatch(patt, p->name))
    if ((!patt || patmatch(patt, p->name)) && !p->hidden)
      cmd(p, arg, cnt++);

  if (!cnt)
@@ -1943,7 +1950,7 @@ proto_get_named(struct symbol *sym, struct protocol *pr)
  {
    p = NULL;
    WALK_LIST(q, proto_list)
      if ((q->proto == pr) && (q->proto_state != PS_DOWN))
      if ((q->proto == pr) && (q->proto_state != PS_DOWN) && !q->hidden)
      {
	if (p)
	  cf_error("There are multiple %s protocols running", pr->name);
+2 −0
Original line number Diff line number Diff line
@@ -96,6 +96,7 @@ struct proto_config {
  int class;				/* SYM_PROTO or SYM_TEMPLATE */
  u8 net_type;				/* Protocol network type (NET_*), 0 for undefined */
  u8 disabled;				/* Protocol enabled/disabled by default */
  byte hidden;				/* Protocol not showed in show protocols */
  u32 debug, mrtdump;			/* Debugging bitfields, both use D_* constants */
  u32 router_id;			/* Protocol specific router ID */

@@ -160,6 +161,7 @@ struct proto {
  byte gr_recovery;			/* Protocol should participate in graceful restart recovery */
  byte down_sched;			/* Shutdown is scheduled for later (PDS_*) */
  byte down_code;			/* Reason for shutdown (PDC_* codes) */
  byte hidden;				/* Protocol not showed in show protocols */
  u32 hash_key;				/* Random key used for hashing of neighbors */
  btime last_state_change;		/* Time of last state transition */
  char *last_state_name_announced;	/* Last state name we've announced to the user */
Loading