0
0
mirror of https://gitlab.nic.cz/labs/bird.git synced 2024-10-18 09:58:43 +00:00

Merge commit '300e4008f02382b87409dabb52a317b8336de55b' into integrated

Conflicts:

	nest/neighbor.c
This commit is contained in:
Ondrej Zajicek 2014-04-29 16:40:23 +02:00
commit 91ea1b134b
6 changed files with 48 additions and 18 deletions

View File

@ -707,6 +707,9 @@ This argument can be omitted if there exists only a single instance.
that is routes, their metrics and (in case the <cf/all/ switch is given) that is routes, their metrics and (in case the <cf/all/ switch is given)
all their attributes. all their attributes.
<tag>show bfd sessions [<m/name/]</tag>
Show information about BFD sessions.
<p>You can specify a <m/prefix/ if you want to print routes for a <p>You can specify a <m/prefix/ if you want to print routes for a
specific network. If you use <cf>for <m/prefix or IP/</cf>, you'll get specific network. If you use <cf>for <m/prefix or IP/</cf>, you'll get
the entry which will be used for forwarding of packets to the given the entry which will be used for forwarding of packets to the given

View File

@ -22,14 +22,19 @@
BIRD4="yes" BIRD4="yes"
BIRD6="yes" BIRD6="yes"
BIRD4ARGS=
BIRD6ARGS=
[ -f /etc/bird.conf ] || BIRD4="no" [ -f /etc/bird.conf ] || BIRD4="no"
[ -f /usr/sbin/bird ] || BIRD4="no" [ -f /usr/sbin/bird ] || BIRD4="no"
[ "${NETWORKING}" = "yes" ] || BIRD4="no" [ "${NETWORKING}" = "yes" ] || BIRD4="no"
[ -f /etc/bird-6.conf ] || BIRD6="no" [ -f /etc/bird6.conf ] || BIRD6="no"
[ -f /usr/sbin/bird6 ] || BIRD6="no" [ -f /usr/sbin/bird6 ] || BIRD6="no"
[ "${NETWORKING_IPV6}" = "yes" ] || BIRD6="no" [ "${NETWORKING_IPV6}" = "yes" ] || BIRD6="no"
[ -e /etc/sysconfig/bird ] && . /etc/sysconfig/bird
RETVAL=0 RETVAL=0
# See how we were called. # See how we were called.
@ -38,7 +43,7 @@ case "$1" in
if [ "$BIRD4" = "yes" ] if [ "$BIRD4" = "yes" ]
then then
echo -n "Starting BIRD for IPv4: " echo -n "Starting BIRD for IPv4: "
daemon bird daemon bird ${BIRD4ARGS}
RETVAL=$? RETVAL=$?
echo echo
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/bird [ $RETVAL -eq 0 ] && touch /var/lock/subsys/bird
@ -46,7 +51,7 @@ case "$1" in
if [ "$BIRD6" = "yes" ] if [ "$BIRD6" = "yes" ]
then then
echo -n "Starting BIRD for IPv6: " echo -n "Starting BIRD for IPv6: "
daemon bird6 daemon bird6 ${BIRD6ARGS}
RETVAL=$? RETVAL=$?
echo echo
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/bird6 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/bird6
@ -76,13 +81,17 @@ case "$1" in
RETVAL=$? RETVAL=$?
;; ;;
reload) reload)
killall -HUP bird killproc bird -HUP
killall -HUP bird6 RETVAL=$?
echo
echo -n "Reloading BIRD for IPv6: "
killproc bird6 -HUP
RETVAL=$? RETVAL=$?
echo
;; ;;
*) *)
echo "Usage: bird.init {start|stop|status|restart|reload}" echo "Usage: bird.init {start|stop|status|restart|reload}"
exit 1 exit 1
esac esac
exit $REVAL exit $RETVAL

View File

@ -108,6 +108,7 @@ typedef struct neighbor {
node n; /* Node in global neighbor list */ node n; /* Node in global neighbor list */
node if_n; /* Node in per-interface neighbor list */ node if_n; /* Node in per-interface neighbor list */
ip_addr addr; /* Address of the neighbor */ ip_addr addr; /* Address of the neighbor */
struct ifa *ifa; /* Ifa on related iface */
struct iface *iface; /* Interface it's connected to */ struct iface *iface; /* Interface it's connected to */
struct proto *proto; /* Protocol this belongs to */ struct proto *proto; /* Protocol this belongs to */
void *data; /* Protocol-specific data */ void *data; /* Protocol-specific data */

View File

@ -56,14 +56,20 @@ neigh_hash(struct proto *p, ip_addr *a)
} }
static int static int
if_connected(ip_addr *a, struct iface *i) /* -1=error, 1=match, 0=no match */ if_connected(ip_addr *a, struct iface *i, struct ifa **ap)
{ {
struct ifa *b; struct ifa *b;
if (!(i->flags & IF_UP)) if (!(i->flags & IF_UP))
{
*ap = NULL;
return -1; return -1;
}
WALK_LIST(b, i->addrs) WALK_LIST(b, i->addrs)
{ {
*ap = b;
if (ipa_equal(*a, b->ip)) if (ipa_equal(*a, b->ip))
return SCOPE_HOST; return SCOPE_HOST;
if (b->flags & IA_PEER) if (b->flags & IA_PEER)
@ -79,12 +85,17 @@ if_connected(ip_addr *a, struct iface *i) /* -1=error, 1=match, 0=no match */
if ((b->pxlen < (BITS_PER_IP_ADDRESS - 1)) && if ((b->pxlen < (BITS_PER_IP_ADDRESS - 1)) &&
(ipa_equal(*a, b->prefix) || /* Network address */ (ipa_equal(*a, b->prefix) || /* Network address */
ipa_equal(*a, b->brd))) /* Broadcast */ ipa_equal(*a, b->brd))) /* Broadcast */
{
*ap = NULL;
return -1; return -1;
}
return b->scope; return b->scope;
} }
} }
} }
*ap = NULL;
return -1; return -1;
} }
@ -116,6 +127,7 @@ neigh_find2(struct proto *p, ip_addr *a, struct iface *ifa, unsigned flags)
int class, scope = -1; int class, scope = -1;
unsigned int h = neigh_hash(p, a); unsigned int h = neigh_hash(p, a);
struct iface *i; struct iface *i;
struct ifa *addr;
WALK_LIST(n, neigh_hash_table[h]) /* Search the cache */ WALK_LIST(n, neigh_hash_table[h]) /* Search the cache */
if (n->proto == p && ipa_equal(*a, n->addr) && (!ifa || (ifa == n->iface))) if (n->proto == p && ipa_equal(*a, n->addr) && (!ifa || (ifa == n->iface)))
@ -131,7 +143,7 @@ neigh_find2(struct proto *p, ip_addr *a, struct iface *ifa, unsigned flags)
if (ifa) if (ifa)
{ {
scope = if_connected(a, ifa); scope = if_connected(a, ifa, &addr);
flags |= NEF_BIND; flags |= NEF_BIND;
if ((scope < 0) && (flags & NEF_ONLINK)) if ((scope < 0) && (flags & NEF_ONLINK))
@ -139,7 +151,7 @@ neigh_find2(struct proto *p, ip_addr *a, struct iface *ifa, unsigned flags)
} }
else else
WALK_LIST(i, iface_list) WALK_LIST(i, iface_list)
if ((scope = if_connected(a, i)) >= 0) if ((scope = if_connected(a, i, &addr)) >= 0)
{ {
ifa = i; ifa = i;
break; break;
@ -164,6 +176,7 @@ neigh_find2(struct proto *p, ip_addr *a, struct iface *ifa, unsigned flags)
scope = -1; scope = -1;
} }
n->iface = ifa; n->iface = ifa;
n->ifa = addr;
n->proto = p; n->proto = p;
n->data = NULL; n->data = NULL;
n->aux = 0; n->aux = 0;
@ -215,9 +228,10 @@ neigh_dump_all(void)
} }
static void static void
neigh_up(neighbor *n, struct iface *i, int scope) neigh_up(neighbor *n, struct iface *i, int scope, struct ifa *a)
{ {
n->iface = i; n->iface = i;
n->ifa = a;
n->scope = scope; n->scope = scope;
add_tail(&i->neighbors, &n->if_n); add_tail(&i->neighbors, &n->if_n);
rem_node(&n->n); rem_node(&n->n);
@ -234,6 +248,7 @@ neigh_down(neighbor *n)
rem_node(&n->if_n); rem_node(&n->if_n);
if (! (n->flags & NEF_BIND)) if (! (n->flags & NEF_BIND))
n->iface = NULL; n->iface = NULL;
n->ifa = NULL;
n->scope = -1; n->scope = -1;
if (n->proto->neigh_notify && n->proto->core_state != FS_FLUSHING) if (n->proto->neigh_notify && n->proto->core_state != FS_FLUSHING)
n->proto->neigh_notify(n); n->proto->neigh_notify(n);
@ -244,13 +259,14 @@ neigh_down(neighbor *n)
/* Respawn neighbor if there is another matching prefix */ /* Respawn neighbor if there is another matching prefix */
struct iface *i; struct iface *i;
struct ifa *a;
int scope; int scope;
if (!n->iface) if (!n->iface)
WALK_LIST(i, iface_list) WALK_LIST(i, iface_list)
if ((scope = if_connected(&n->addr, i)) >= 0) if ((scope = if_connected(&n->addr, i, &a)) >= 0)
{ {
neigh_up(n, i, scope); neigh_up(n, i, scope, a);
return; return;
} }
} }
@ -271,13 +287,14 @@ neigh_down(neighbor *n)
void void
neigh_if_up(struct iface *i) neigh_if_up(struct iface *i)
{ {
struct ifa *a;
neighbor *n, *next; neighbor *n, *next;
int scope; int scope;
WALK_LIST_DELSAFE(n, next, sticky_neigh_list) WALK_LIST_DELSAFE(n, next, sticky_neigh_list)
if ((!n->iface || n->iface == i) && if ((!n->iface || n->iface == i) &&
((scope = if_connected(&n->addr, i)) >= 0)) ((scope = if_connected(&n->addr, i, &a)) >= 0))
neigh_up(n, i, scope); neigh_up(n, i, scope, a);
} }
/** /**
@ -338,8 +355,9 @@ neigh_ifa_update(struct ifa *a)
/* Remove all neighbors whose scope has changed */ /* Remove all neighbors whose scope has changed */
WALK_LIST_DELSAFE(x, y, i->neighbors) WALK_LIST_DELSAFE(x, y, i->neighbors)
{ {
struct ifa *aa;
neighbor *n = SKIP_BACK(neighbor, if_n, x); neighbor *n = SKIP_BACK(neighbor, if_n, x);
if (if_connected(&n->addr, i) != n->scope) if (if_connected(&n->addr, i, &aa) != n->scope)
neigh_down(n); neigh_down(n);
} }

View File

@ -740,7 +740,7 @@ bfd_neigh_notify(struct neighbor *nb)
if ((nb->scope > 0) && !n->req) if ((nb->scope > 0) && !n->req)
{ {
ip_addr local = ipa_nonzero(n->local) ? n->local : nb->iface->addr->ip; ip_addr local = ipa_nonzero(n->local) ? n->local : nb->ifa->ip;
n->req = bfd_request_session(p->p.pool, n->addr, local, nb->iface, NULL, NULL); n->req = bfd_request_session(p->p.pool, n->addr, local, nb->iface, NULL, NULL);
} }

View File

@ -718,9 +718,8 @@ bgp_start_neighbor(struct bgp_proto *p)
{ {
/* Called only for single-hop BGP sessions */ /* Called only for single-hop BGP sessions */
/* Remove this ? */
if (ipa_zero(p->source_addr)) if (ipa_zero(p->source_addr))
p->source_addr = p->neigh->iface->addr->ip; p->source_addr = p->neigh->ifa->ip;
#ifdef IPV6 #ifdef IPV6
{ {