summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bgpd/bgp_zebra.c24
-rw-r--r--lib/prefix.h10
-rw-r--r--lib/vty.c2
-rw-r--r--ospf6d/ospf6_snmp.c2
-rw-r--r--ospfd/ospf_asbr.c3
-rw-r--r--ospfd/ospf_te.c3
-rw-r--r--ospfd/ospf_zebra.c2
-rw-r--r--zebra/irdp_packet.c2
-rw-r--r--zebra/zebra_rib.c20
-rw-r--r--zebra/zserv.c1
10 files changed, 56 insertions, 13 deletions
diff --git a/bgpd/bgp_zebra.c b/bgpd/bgp_zebra.c
index 60443830..26b97c2c 100644
--- a/bgpd/bgp_zebra.c
+++ b/bgpd/bgp_zebra.c
@@ -534,6 +534,25 @@ if_get_ipv6_local (struct interface *ifp, struct in6_addr *addr)
}
#endif /* HAVE_IPV6 */
+static int
+if_get_ipv4_address (struct interface *ifp, struct in_addr *addr)
+{
+ struct listnode *cnode;
+ struct connected *connected;
+ struct prefix *cp;
+
+ for (ALL_LIST_ELEMENTS_RO (ifp->connected, cnode, connected))
+ {
+ cp = connected->address;
+ if ((cp->family == AF_INET) && !ipv4_martian(&(cp->u.prefix4)))
+ {
+ *addr = cp->u.prefix4;
+ return 1;
+ }
+ }
+ return 0;
+}
+
int
bgp_nexthop_set (union sockunion *local, union sockunion *remote,
struct bgp_nexthop *nexthop, struct peer *peer)
@@ -592,8 +611,9 @@ bgp_nexthop_set (union sockunion *local, union sockunion *remote,
{
struct interface *direct = NULL;
- /* IPv4 nexthop. I don't care about it. */
- if (peer->local_id.s_addr)
+ /* IPv4 nexthop. */
+ ret = if_get_ipv4_address(ifp, &nexthop->v4);
+ if (!ret && peer->local_id.s_addr)
nexthop->v4 = peer->local_id;
/* Global address*/
diff --git a/lib/prefix.h b/lib/prefix.h
index 7f0d3607..8c8992e8 100644
--- a/lib/prefix.h
+++ b/lib/prefix.h
@@ -196,4 +196,14 @@ extern const char *inet6_ntoa (struct in6_addr);
extern int all_digit (const char *);
+static inline int ipv4_martian (struct in_addr *addr)
+{
+ in_addr_t ip = addr->s_addr;
+
+ if (IPV4_NET0(ip) || IPV4_NET127(ip) || IPV4_CLASS_DE(ip)) {
+ return 1;
+ }
+ return 0;
+}
+
#endif /* _ZEBRA_PREFIX_H */
diff --git a/lib/vty.c b/lib/vty.c
index 0d6345c8..96cb1e4b 100644
--- a/lib/vty.c
+++ b/lib/vty.c
@@ -1856,9 +1856,11 @@ vty_serv_sock_family (const char* addr, unsigned short port, int family)
{
case AF_INET:
naddr=&su.sin.sin_addr;
+ break;
#ifdef HAVE_IPV6
case AF_INET6:
naddr=&su.sin6.sin6_addr;
+ break;
#endif
}
diff --git a/ospf6d/ospf6_snmp.c b/ospf6d/ospf6_snmp.c
index f8a3b920..46603927 100644
--- a/ospf6d/ospf6_snmp.c
+++ b/ospf6d/ospf6_snmp.c
@@ -528,7 +528,7 @@ ospfv3AreaEntry (struct variable *v, oid *name, size_t *length,
return NULL;
len = *length - v->namelen;
- len = (len >= 1 ? sizeof 1 : 0);
+ len = (len >= 1 ? 1 : 0);
if (exact && len != 1)
return NULL;
if (len)
diff --git a/ospfd/ospf_asbr.c b/ospfd/ospf_asbr.c
index a23b4f2b..7e7c84fd 100644
--- a/ospfd/ospf_asbr.c
+++ b/ospfd/ospf_asbr.c
@@ -164,7 +164,8 @@ ospf_external_info_add (u_char type, struct prefix_ipv4 p,
new->nexthop = nexthop;
new->tag = 0;
- rn->info = new;
+ if (rn)
+ rn->info = new;
if (IS_DEBUG_OSPF (lsa, LSA_GENERATE))
zlog_debug ("Redistribute[%s]: %s/%d external info created.",
diff --git a/ospfd/ospf_te.c b/ospfd/ospf_te.c
index 587564a1..c605ce68 100644
--- a/ospfd/ospf_te.c
+++ b/ospfd/ospf_te.c
@@ -1036,7 +1036,8 @@ ospf_mpls_te_lsa_refresh (struct ospf_lsa *lsa)
/* If the lsa's age reached to MaxAge, start flushing procedure. */
if (IS_LSA_MAXAGE (lsa))
{
- lp->flags &= ~LPFLG_LSA_ENGAGED;
+ if (lp)
+ lp->flags &= ~LPFLG_LSA_ENGAGED;
ospf_opaque_lsa_flush_schedule (lsa);
goto out;
}
diff --git a/ospfd/ospf_zebra.c b/ospfd/ospf_zebra.c
index 34a3b2a7..b5268a3b 100644
--- a/ospfd/ospf_zebra.c
+++ b/ospfd/ospf_zebra.c
@@ -482,7 +482,7 @@ ospf_zebra_delete (struct prefix_ipv4 *p, struct ospf_route *or)
if (IS_DEBUG_OSPF (zebra, ZEBRA_REDISTRIBUTE))
{
char buf[2][INET_ADDRSTRLEN];
- zlog_debug("Zebra: Route add %s/%d nexthop %s",
+ zlog_debug("Zebra: Route delete %s/%d nexthop %s",
inet_ntop(AF_INET, &p->prefix,
buf[0], sizeof(buf[0])),
p->prefixlen,
diff --git a/zebra/irdp_packet.c b/zebra/irdp_packet.c
index 28dc171e..50525043 100644
--- a/zebra/irdp_packet.c
+++ b/zebra/irdp_packet.c
@@ -287,7 +287,7 @@ send_packet(struct interface *ifp,
if (!(ifp->flags & IFF_UP))
return;
- if (!p)
+ if (p)
src = ntohl(p->u.prefix4.s_addr);
else
src = 0; /* Is filled in */
diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c
index 77c0d8ca..6616f9a1 100644
--- a/zebra/zebra_rib.c
+++ b/zebra/zebra_rib.c
@@ -2160,12 +2160,20 @@ rib_delete_ipv4 (int type, int flags, struct prefix_ipv4 *p,
/* Apply mask. */
apply_mask_ipv4 (p);
- if (IS_ZEBRA_DEBUG_KERNEL && gate)
- zlog_debug ("rib_delete_ipv4(): route delete %s/%d via %s ifindex %d",
- inet_ntop (AF_INET, &p->prefix, buf1, INET_ADDRSTRLEN),
- p->prefixlen,
- inet_ntoa (*gate),
- ifindex);
+ if (IS_ZEBRA_DEBUG_KERNEL)
+ {
+ if (gate)
+ zlog_debug ("rib_delete_ipv4(): route delete %s/%d via %s ifindex %d",
+ inet_ntop (AF_INET, &p->prefix, buf1, INET_ADDRSTRLEN),
+ p->prefixlen,
+ inet_ntoa (*gate),
+ ifindex);
+ else
+ zlog_debug ("rib_delete_ipv4(): route delete %s/%d ifindex %d",
+ inet_ntop (AF_INET, &p->prefix, buf1, INET_ADDRSTRLEN),
+ p->prefixlen,
+ ifindex);
+ }
/* Lookup route node. */
rn = route_node_lookup (table, (struct prefix *) p);
diff --git a/zebra/zserv.c b/zebra/zserv.c
index 5df521b0..55ac6e4f 100644
--- a/zebra/zserv.c
+++ b/zebra/zserv.c
@@ -879,6 +879,7 @@ zread_ipv4_delete (struct zserv *client, u_short length)
break;
case ZEBRA_NEXTHOP_IPV4_IFINDEX:
nexthop.s_addr = stream_get_ipv4 (s);
+ nexthop_p = &nexthop;
ifindex = stream_getl (s);
break;
case ZEBRA_NEXTHOP_IPV6: