Beispiel #1
0
/* Delete specified OSPF neighbor from interface. */
void
ospf_nbr_delete (struct ospf_neighbor *nbr)
{
  struct ospf_interface *oi;
  struct route_node *rn;
  struct prefix p;

  oi = nbr->oi;

  /* Unlink ospf neighbor from the interface. */
  p.family = AF_INET;
  p.prefixlen = IPV4_MAX_BITLEN;
  p.u.prefix4 = nbr->src;

  rn = route_node_lookup (oi->nbrs, &p);
  if (rn)
    {
      if (rn->info)
	{
	  rn->info = NULL;
	  route_unlock_node (rn);
	}
      else
	zlog_info ("Can't find neighbor %s in the interface %s",
		   inet_ntoa (nbr->src), IF_NAME (oi));

      route_unlock_node (rn);
    }

  /* Free ospf_neighbor structure. */
  ospf_nbr_free (nbr);
}
Beispiel #2
0
/* Delete specified OSPF neighbor from interface. */
void ospf_nbr_delete(struct ospf_neighbor *nbr)
{
	struct ospf_interface *oi;
	struct route_node *rn;
	struct prefix p;

	oi = nbr->oi;

	/* get appropriate prefix 'key' */
	ospf_nbr_key(oi, nbr, &p);

	rn = route_node_lookup(oi->nbrs, &p);
	if (rn) {
		/* If lookup for a NBR succeeds, the leaf route_node could
		 * only exist because there is (or was) a nbr there.
		 * If the nbr was deleted, the leaf route_node should have
		 * lost its last refcount too, and be deleted.
		 * Therefore a looked-up leaf route_node in nbrs table
		 * should never have NULL info.
		 */
		assert(rn->info);

		if (rn->info) {
			rn->info = NULL;
			route_unlock_node(rn);
		} else
			zlog_info("Can't find neighbor %s in the interface %s",
				  inet_ntoa(nbr->src), IF_NAME(oi));

		route_unlock_node(rn);
	}

	/* Free ospf_neighbor structure. */
	ospf_nbr_free(nbr);
}
Beispiel #3
0
/* Delete specified OSPF neighbor from interface. */
void ospf_nbr_delete(struct ospf_neighbor *nbr)
{
	struct ospf_interface *oi;
	struct route_node *rn;
	struct prefix p;

	oi = nbr->oi;

	/* get appropriate prefix 'key' */
	ospf_nbr_key(oi, nbr, &p);

	rn = route_node_lookup(oi->nbrs, &p);
	if (rn) {
		/* If lookup for a NBR succeeds, the leaf route_node could
		 * only exist because there is (or was) a nbr there.
		 * If the nbr was deleted, the leaf route_node should have
		 * lost its last refcount too, and be deleted.
		 * Therefore a looked-up leaf route_node in nbrs table
		 * should never have NULL info.
		 */
		assert(rn->info);

		if (rn->info) {
			rn->info = NULL;
			route_unlock_node(rn);
		} else
			zlog_info("Can't find neighbor %s in the interface %s",
				  inet_ntoa(nbr->src), IF_NAME(oi));

		route_unlock_node(rn);
	} else {
		/*
		 * This neighbor was not found, but before we move on and
		 * free the neighbor structre, make sure that it was not
		 * indexed incorrectly and ended up in the "worng" place
		 */

		/* Reverse the lookup rules */
		if (oi->type == OSPF_IFTYPE_VIRTUALLINK
		    || oi->type == OSPF_IFTYPE_POINTOPOINT)
			p.u.prefix4 = nbr->src;
		else
			p.u.prefix4 = nbr->router_id;

		rn = route_node_lookup(oi->nbrs, &p);
		if (rn) {
			/* We found the neighbor!
			 * Now make sure it is not the exact same neighbor
			 * structure that we are about to free
			 */
			if (nbr == rn->info) {
				/* Same neighbor, drop the reference to it */
				rn->info = NULL;
				route_unlock_node(rn);
			}
			route_unlock_node(rn);
		}
	}

	/* Free ospf_neighbor structure. */
	ospf_nbr_free(nbr);
}