mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-07 10:49:24 +00:00
2003-09-29 Paul Jakma <paul@dishone.st>
* zebra/connected.c: revert the 'generic PtP' patch as it causes far too many problems. People who use FreeSWAN should investigate native linux ipsec. * zebra/rt_netlink.c: ditto * lib/if.c: ditto * ripd/ripd.h: ditto * ripd/ripd.c: ditto * ripd/rip_interface.c: ditto * ospfd/ospfd.c: ditto * ospfd/ospf_snmp.c: ditto * bgpd/bgp_nexthop.c: ditto
This commit is contained in:
parent
f3e05cda2a
commit
31a476c7e9
@ -663,7 +663,7 @@ bgp_connected_add (struct connected *ifc)
|
|||||||
p.family = AF_INET;
|
p.family = AF_INET;
|
||||||
p.prefixlen = addr->prefixlen;
|
p.prefixlen = addr->prefixlen;
|
||||||
|
|
||||||
if (ifc_pointopoint (ifc))
|
if (if_is_pointopoint (ifp))
|
||||||
p.u.prefix4 = dest->u.prefix4;
|
p.u.prefix4 = dest->u.prefix4;
|
||||||
else
|
else
|
||||||
p.u.prefix4 = addr->u.prefix4;
|
p.u.prefix4 = addr->u.prefix4;
|
||||||
@ -694,7 +694,7 @@ bgp_connected_add (struct connected *ifc)
|
|||||||
p.family = AF_INET6;
|
p.family = AF_INET6;
|
||||||
p.prefixlen = addr->prefixlen;
|
p.prefixlen = addr->prefixlen;
|
||||||
|
|
||||||
if (ifc_pointopoint (ifc))
|
if (if_is_pointopoint (ifp))
|
||||||
p.u.prefix6 = dest->u.prefix6;
|
p.u.prefix6 = dest->u.prefix6;
|
||||||
else
|
else
|
||||||
p.u.prefix6 = addr->u.prefix6;
|
p.u.prefix6 = addr->u.prefix6;
|
||||||
@ -748,7 +748,7 @@ bgp_connected_delete (struct connected *ifc)
|
|||||||
p.family = AF_INET;
|
p.family = AF_INET;
|
||||||
p.prefixlen = addr->prefixlen;
|
p.prefixlen = addr->prefixlen;
|
||||||
|
|
||||||
if (ifc_pointopoint (ifc))
|
if (if_is_pointopoint (ifp))
|
||||||
p.u.prefix4 = dest->u.prefix4;
|
p.u.prefix4 = dest->u.prefix4;
|
||||||
else
|
else
|
||||||
p.u.prefix4 = addr->u.prefix4;
|
p.u.prefix4 = addr->u.prefix4;
|
||||||
@ -779,7 +779,7 @@ bgp_connected_delete (struct connected *ifc)
|
|||||||
p.family = AF_INET6;
|
p.family = AF_INET6;
|
||||||
p.prefixlen = addr->prefixlen;
|
p.prefixlen = addr->prefixlen;
|
||||||
|
|
||||||
if (ifc_pointopoint (ifc))
|
if (if_is_pointopoint (ifp))
|
||||||
p.u.prefix6 = dest->u.prefix6;
|
p.u.prefix6 = dest->u.prefix6;
|
||||||
else
|
else
|
||||||
p.u.prefix6 = addr->u.prefix6;
|
p.u.prefix6 = addr->u.prefix6;
|
||||||
|
34
lib/if.c
34
lib/if.c
@ -245,13 +245,11 @@ if_lookup_address (struct in_addr src)
|
|||||||
listnode node;
|
listnode node;
|
||||||
struct prefix addr;
|
struct prefix addr;
|
||||||
struct prefix best;
|
struct prefix best;
|
||||||
struct prefix peer;
|
|
||||||
listnode cnode;
|
listnode cnode;
|
||||||
struct interface *ifp;
|
struct interface *ifp;
|
||||||
struct prefix *p;
|
struct prefix *p;
|
||||||
struct connected *c;
|
struct connected *c;
|
||||||
struct interface *match;
|
struct interface *match;
|
||||||
int prefixlen;
|
|
||||||
|
|
||||||
/* Zero structures - get rid of rubbish from stack */
|
/* Zero structures - get rid of rubbish from stack */
|
||||||
memset(&addr, 0, sizeof(addr));
|
memset(&addr, 0, sizeof(addr));
|
||||||
@ -270,24 +268,34 @@ if_lookup_address (struct in_addr src)
|
|||||||
for (cnode = listhead (ifp->connected); cnode; nextnode (cnode))
|
for (cnode = listhead (ifp->connected); cnode; nextnode (cnode))
|
||||||
{
|
{
|
||||||
c = getdata (cnode);
|
c = getdata (cnode);
|
||||||
p = c->address;
|
|
||||||
|
|
||||||
if (p->family == AF_INET)
|
if (if_is_pointopoint (ifp))
|
||||||
{
|
{
|
||||||
prefixlen = p->prefixlen;
|
p = c->address;
|
||||||
|
|
||||||
if (if_is_pointopoint (ifp) ||
|
if (p && p->family == AF_INET)
|
||||||
prefixlen >= IPV4_MAX_PREFIXLEN - 1)
|
|
||||||
{
|
{
|
||||||
peer = *c->destination;
|
#ifdef OLD_RIB /* PTP links are conventionally identified
|
||||||
peer.prefixlen = prefixlen;
|
by the address of the far end - MAG */
|
||||||
p = &peer;
|
if (IPV4_ADDR_SAME (&p->u.prefix4, &src))
|
||||||
|
return ifp;
|
||||||
|
#endif
|
||||||
|
p = c->destination;
|
||||||
|
if (p && IPV4_ADDR_SAME (&p->u.prefix4, &src))
|
||||||
|
return ifp;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
p = c->address;
|
||||||
|
|
||||||
if (prefix_match (p, &addr) && prefixlen > best.prefixlen)
|
if (p->family == AF_INET)
|
||||||
{
|
{
|
||||||
best = *p;
|
if (prefix_match (p, &addr) && p->prefixlen > best.prefixlen)
|
||||||
match = ifp;
|
{
|
||||||
|
best = *p;
|
||||||
|
match = ifp;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1440,7 +1440,7 @@ ospf_snmp_if_update (struct interface *ifp)
|
|||||||
/* Lookup first IPv4 address entry. */
|
/* Lookup first IPv4 address entry. */
|
||||||
LIST_LOOP (ifp->connected, ifc, nn)
|
LIST_LOOP (ifp->connected, ifc, nn)
|
||||||
{
|
{
|
||||||
if (ifc_pointopoint (ifc))
|
if (if_is_pointopoint (ifp))
|
||||||
p = ifc->destination;
|
p = ifc->destination;
|
||||||
else
|
else
|
||||||
p = ifc->address;
|
p = ifc->address;
|
||||||
|
@ -714,7 +714,7 @@ ospf_network_match_iface(struct connected *co, struct prefix *net)
|
|||||||
* PtP special case: network specified == iface peer addr -> ospf
|
* PtP special case: network specified == iface peer addr -> ospf
|
||||||
*/
|
*/
|
||||||
return (
|
return (
|
||||||
((ifc_pointopoint (co) &&
|
((if_is_pointopoint (co) &&
|
||||||
IPV4_ADDR_SAME ( &(co->destination->u.prefix4), &(net->u.prefix4)))
|
IPV4_ADDR_SAME ( &(co->destination->u.prefix4), &(net->u.prefix4)))
|
||||||
|| prefix_match (net, co->address))
|
|| prefix_match (net, co->address))
|
||||||
? 1 : 0
|
? 1 : 0
|
||||||
@ -756,7 +756,7 @@ ospf_network_run (struct ospf *ospf, struct prefix *p, struct ospf_area *area)
|
|||||||
if (CHECK_FLAG(co->flags,ZEBRA_IFA_SECONDARY))
|
if (CHECK_FLAG(co->flags,ZEBRA_IFA_SECONDARY))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (ifc_pointopoint (co))
|
if (if_is_pointopoint (co))
|
||||||
addr = co->destination;
|
addr = co->destination;
|
||||||
else
|
else
|
||||||
addr = co->address;
|
addr = co->address;
|
||||||
|
@ -396,6 +396,106 @@ rip_if_ipv4_address_check (struct interface *ifp)
|
|||||||
|
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Does this address belongs to me ? */
|
||||||
|
int
|
||||||
|
if_check_address (struct in_addr addr)
|
||||||
|
{
|
||||||
|
listnode node;
|
||||||
|
|
||||||
|
for (node = listhead (iflist); node; nextnode (node))
|
||||||
|
{
|
||||||
|
listnode cnode;
|
||||||
|
struct interface *ifp;
|
||||||
|
|
||||||
|
ifp = getdata (node);
|
||||||
|
|
||||||
|
for (cnode = listhead (ifp->connected); cnode; nextnode (cnode))
|
||||||
|
{
|
||||||
|
struct connected *connected;
|
||||||
|
struct prefix_ipv4 *p;
|
||||||
|
|
||||||
|
connected = getdata (cnode);
|
||||||
|
p = (struct prefix_ipv4 *) connected->address;
|
||||||
|
|
||||||
|
if (p->family != AF_INET)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (IPV4_ADDR_CMP (&p->prefix, &addr) == 0)
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* is this address from a valid neighbor? (RFC2453 - Sec. 3.9.2) */
|
||||||
|
int
|
||||||
|
if_valid_neighbor (struct in_addr addr)
|
||||||
|
{
|
||||||
|
listnode node;
|
||||||
|
struct connected *connected = NULL;
|
||||||
|
struct prefix_ipv4 *p;
|
||||||
|
|
||||||
|
for (node = listhead (iflist); node; nextnode (node))
|
||||||
|
{
|
||||||
|
listnode cnode;
|
||||||
|
struct interface *ifp;
|
||||||
|
|
||||||
|
ifp = getdata (node);
|
||||||
|
|
||||||
|
for (cnode = listhead (ifp->connected); cnode; nextnode (cnode))
|
||||||
|
{
|
||||||
|
struct prefix *pxn = NULL; /* Prefix of the neighbor */
|
||||||
|
struct prefix *pxc = NULL; /* Prefix of the connected network */
|
||||||
|
|
||||||
|
connected = getdata (cnode);
|
||||||
|
|
||||||
|
if (if_is_pointopoint (ifp))
|
||||||
|
{
|
||||||
|
p = (struct prefix_ipv4 *) connected->address;
|
||||||
|
|
||||||
|
if (p && p->family == AF_INET)
|
||||||
|
{
|
||||||
|
if (IPV4_ADDR_SAME (&p->prefix, &addr))
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
p = (struct prefix_ipv4 *) connected->destination;
|
||||||
|
if (p && IPV4_ADDR_SAME (&p->prefix, &addr))
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
p = (struct prefix_ipv4 *) connected->address;
|
||||||
|
|
||||||
|
if (p->family != AF_INET)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
pxn = prefix_new();
|
||||||
|
pxn->family = AF_INET;
|
||||||
|
pxn->prefixlen = 32;
|
||||||
|
pxn->u.prefix4 = addr;
|
||||||
|
|
||||||
|
pxc = prefix_new();
|
||||||
|
prefix_copy(pxc, (struct prefix *) p);
|
||||||
|
apply_mask(pxc);
|
||||||
|
|
||||||
|
if (prefix_match (pxc, pxn))
|
||||||
|
{
|
||||||
|
prefix_free (pxn);
|
||||||
|
prefix_free (pxc);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
prefix_free(pxc);
|
||||||
|
prefix_free(pxn);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* Inteface link down message processing. */
|
/* Inteface link down message processing. */
|
||||||
int
|
int
|
||||||
|
@ -1017,7 +1017,7 @@ rip_response_process (struct rip_packet *packet, int size,
|
|||||||
/* The datagram's IPv4 source address should be checked to see
|
/* The datagram's IPv4 source address should be checked to see
|
||||||
whether the datagram is from a valid neighbor; the source of the
|
whether the datagram is from a valid neighbor; the source of the
|
||||||
datagram must be on a directly connected network */
|
datagram must be on a directly connected network */
|
||||||
if (if_lookup_address (from->sin_addr) == NULL)
|
if (! if_valid_neighbor (from->sin_addr))
|
||||||
{
|
{
|
||||||
zlog_info ("This datagram doesn't came from a valid neighbor: %s",
|
zlog_info ("This datagram doesn't came from a valid neighbor: %s",
|
||||||
inet_ntoa (from->sin_addr));
|
inet_ntoa (from->sin_addr));
|
||||||
@ -1602,7 +1602,7 @@ rip_read (struct thread *t)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Check is this packet comming from myself? */
|
/* Check is this packet comming from myself? */
|
||||||
if (if_lookup_exact_address (from.sin_addr))
|
if (if_check_address (from.sin_addr))
|
||||||
{
|
{
|
||||||
if (IS_RIP_DEBUG_PACKET)
|
if (IS_RIP_DEBUG_PACKET)
|
||||||
zlog_warn ("ignore packet comes from myself");
|
zlog_warn ("ignore packet comes from myself");
|
||||||
|
@ -374,6 +374,8 @@ void rip_zclient_init ();
|
|||||||
void rip_zclient_start ();
|
void rip_zclient_start ();
|
||||||
void rip_zclient_reset ();
|
void rip_zclient_reset ();
|
||||||
void rip_offset_init ();
|
void rip_offset_init ();
|
||||||
|
int if_check_address (struct in_addr addr);
|
||||||
|
int if_valid_neighbor (struct in_addr addr);
|
||||||
|
|
||||||
int rip_request_send (struct sockaddr_in *, struct interface *, u_char);
|
int rip_request_send (struct sockaddr_in *, struct interface *, u_char);
|
||||||
int rip_neighbor_lookup (struct sockaddr_in *);
|
int rip_neighbor_lookup (struct sockaddr_in *);
|
||||||
|
@ -69,7 +69,7 @@ connected_up_ipv4 (struct interface *ifp, struct connected *ifc)
|
|||||||
p.prefixlen = addr->prefixlen;
|
p.prefixlen = addr->prefixlen;
|
||||||
|
|
||||||
/* Point-to-point check. */
|
/* Point-to-point check. */
|
||||||
if (ifc_pointopoint (ifc) && dest)
|
if (if_is_pointopoint (ifc) && dest)
|
||||||
p.prefix = dest->prefix;
|
p.prefix = dest->prefix;
|
||||||
else
|
else
|
||||||
p.prefix = addr->prefix;
|
p.prefix = addr->prefix;
|
||||||
@ -163,7 +163,7 @@ connected_down_ipv4 (struct interface *ifp, struct connected *ifc)
|
|||||||
p.prefixlen = addr->prefixlen;
|
p.prefixlen = addr->prefixlen;
|
||||||
|
|
||||||
/* Point-to-point check. */
|
/* Point-to-point check. */
|
||||||
if (dest && ifc_pointopoint (ifc))
|
if (dest && if_is_pointopoint (ifc))
|
||||||
p.prefix = dest->prefix;
|
p.prefix = dest->prefix;
|
||||||
else
|
else
|
||||||
p.prefix = addr->prefix;
|
p.prefix = addr->prefix;
|
||||||
@ -250,7 +250,7 @@ connected_up_ipv6 (struct interface *ifp, struct connected *ifc)
|
|||||||
p.family = AF_INET6;
|
p.family = AF_INET6;
|
||||||
p.prefixlen = addr->prefixlen;
|
p.prefixlen = addr->prefixlen;
|
||||||
|
|
||||||
if (ifc_pointopoint (ifc) && dest)
|
if (if_is_pointopoint (ifp) && dest)
|
||||||
{
|
{
|
||||||
if (IN6_IS_ADDR_UNSPECIFIED (&dest->prefix))
|
if (IN6_IS_ADDR_UNSPECIFIED (&dest->prefix))
|
||||||
p.prefix = addr->prefix;
|
p.prefix = addr->prefix;
|
||||||
@ -343,7 +343,7 @@ connected_down_ipv6 (struct interface *ifp, struct connected *ifc)
|
|||||||
p.family = AF_INET6;
|
p.family = AF_INET6;
|
||||||
p.prefixlen = addr->prefixlen;
|
p.prefixlen = addr->prefixlen;
|
||||||
|
|
||||||
if (ifc_pointopoint (ifc) && dest)
|
if (if_is_pointopoint (ifp) && dest)
|
||||||
{
|
{
|
||||||
if (IN6_IS_ADDR_UNSPECIFIED (&dest->prefix))
|
if (IN6_IS_ADDR_UNSPECIFIED (&dest->prefix))
|
||||||
p.prefix = addr->prefix;
|
p.prefix = addr->prefix;
|
||||||
|
@ -487,7 +487,6 @@ netlink_interface_addr (struct sockaddr_nl *snl, struct nlmsghdr *h)
|
|||||||
void *broad = NULL;
|
void *broad = NULL;
|
||||||
u_char flags = 0;
|
u_char flags = 0;
|
||||||
char *label = NULL;
|
char *label = NULL;
|
||||||
int peeronly = 0;
|
|
||||||
|
|
||||||
ifa = NLMSG_DATA (h);
|
ifa = NLMSG_DATA (h);
|
||||||
|
|
||||||
@ -539,40 +538,41 @@ netlink_interface_addr (struct sockaddr_nl *snl, struct nlmsghdr *h)
|
|||||||
if (tb[IFA_LABEL] && strcmp (ifp->name, RTA_DATA (tb[IFA_LABEL])))
|
if (tb[IFA_LABEL] && strcmp (ifp->name, RTA_DATA (tb[IFA_LABEL])))
|
||||||
zlog_info (" IFA_LABEL %s", RTA_DATA (tb[IFA_LABEL]));
|
zlog_info (" IFA_LABEL %s", RTA_DATA (tb[IFA_LABEL]));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* peer or broadcast network? */
|
if (tb[IFA_ADDRESS] == NULL)
|
||||||
if (ifa->ifa_family == AF_INET)
|
tb[IFA_ADDRESS] = tb[IFA_LOCAL];
|
||||||
peeronly = if_is_pointopoint (ifp) ||
|
|
||||||
ifa->ifa_prefixlen >= IPV4_MAX_PREFIXLEN - 1;
|
if (ifp->flags & IFF_POINTOPOINT)
|
||||||
#ifdef HAVE_IPV6
|
|
||||||
if (ifa->ifa_family == AF_INET6)
|
|
||||||
{
|
{
|
||||||
peeronly = if_is_pointopoint (ifp) ||
|
if (tb[IFA_LOCAL])
|
||||||
ifa->ifa_prefixlen >= IPV6_MAX_PREFIXLEN - 1;
|
{
|
||||||
|
addr = RTA_DATA (tb[IFA_LOCAL]);
|
||||||
|
if (tb[IFA_ADDRESS])
|
||||||
|
broad = RTA_DATA (tb[IFA_ADDRESS]);
|
||||||
|
else
|
||||||
|
broad = NULL;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (tb[IFA_ADDRESS])
|
||||||
|
addr = RTA_DATA (tb[IFA_ADDRESS]);
|
||||||
|
else
|
||||||
|
addr = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif /* HAVE_IPV6 */
|
else
|
||||||
if (!(tb[IFA_LOCAL] && tb[IFA_ADDRESS]))
|
|
||||||
{
|
{
|
||||||
/* FIXME: IPv6 Appears to have only IFA_ADDRESS */
|
if (tb[IFA_ADDRESS])
|
||||||
peeronly = 0;
|
addr = RTA_DATA (tb[IFA_ADDRESS]);
|
||||||
|
else
|
||||||
|
addr = NULL;
|
||||||
|
|
||||||
|
if (tb[IFA_BROADCAST])
|
||||||
|
broad = RTA_DATA(tb[IFA_BROADCAST]);
|
||||||
|
else
|
||||||
|
broad = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* network. prefixlen applies to IFA_ADDRESS rather than IFA_LOCAL */
|
|
||||||
if (tb[IFA_ADDRESS] && !peeronly)
|
|
||||||
addr = RTA_DATA (tb[IFA_ADDRESS]);
|
|
||||||
else if (tb[IFA_LOCAL])
|
|
||||||
addr = RTA_DATA (tb[IFA_LOCAL]);
|
|
||||||
else
|
|
||||||
addr = NULL;
|
|
||||||
|
|
||||||
/* broadcast/peer */
|
|
||||||
if (tb[IFA_BROADCAST])
|
|
||||||
broad = RTA_DATA (tb[IFA_BROADCAST]);
|
|
||||||
else if (tb[IFA_ADDRESS] && peeronly)
|
|
||||||
broad = RTA_DATA (tb[IFA_ADDRESS]); /* peer address specified */
|
|
||||||
else
|
|
||||||
broad = NULL;
|
|
||||||
|
|
||||||
/* Flags. */
|
/* Flags. */
|
||||||
if (ifa->ifa_flags & IFA_F_SECONDARY)
|
if (ifa->ifa_flags & IFA_F_SECONDARY)
|
||||||
SET_FLAG (flags, ZEBRA_IFA_SECONDARY);
|
SET_FLAG (flags, ZEBRA_IFA_SECONDARY);
|
||||||
|
Loading…
Reference in New Issue
Block a user