diff options
| author | ajs <ajs> | 2005-04-02 18:38:43 +0000 | 
|---|---|---|
| committer | ajs <ajs> | 2005-04-02 18:38:43 +0000 | 
| commit | d2fc88962a9a494ecb34167871bb9e7273a25d33 (patch) | |
| tree | 304a1c1a744972bc10b1f677a134907c404b361d /ospf6d | |
| parent | 386e61502d391adb985ac1487825349ec85e6a8c (diff) | |
2005-04-02 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
	Fix problems when netlink interfaces are renamed (same ifindex used
	for a new interface).  Start cleaning up some problems with the way
	interface names are handled.
	* interface.c: (if_new_intern_ifindex) Remove obsolete function.
	  (if_delete_update) After distributing the interface deletion message,
	  set ifp->ifindex to IFINDEX_INTERNAL.
	  (if_dump_vty) Detect pseudo interface by checking if ifp->ifindex is
	  IFINDEX_INTERNAL.
	  (zebra_interface) Check return code from interface_cmd.func.
	  Do not set internal ifindex values to if_new_intern_ifindex(),
	  since we now use IFINDEX_INTERNAL for all pseudo interfaces.
	* kernel_socket.c: (ifm_read) Fix code and comments to reflect that
	  all internal interfaces now have ifp->ifindex set to IFINDEX_INTERNAL.
        * rt_netlink.c: (set_ifindex) New function used to update ifp->ifindex.
	  Detects interface rename events by checking if that ifindex is already
	  being used.  If it is, delete the old interface before assigning
	  the ifindex to the new interface.
	  (netlink_interface, netlink_link_change) Call set_ifindex to update
	  the ifindex.
	* if.h: Remove define for IFINDEX_INTERNBASE and add define
	  IFINDEX_INTERNAL 0, since all internal (i.e. non-kernel) pseudo-
	  interfaces should have ifindex set to 0.
	  (if_new) Remove function.
	  (if_delete_retain) New function to delete an interface without
	  removing from iflist and freeing the structure.
	  (ifname2ifindex) New function.
	* if.c: (if_new) Remove function (absorb into if_create).
	  (if_create) Replace function if_new with call to calloc.
	  Set ifp->ifindex to IFINDEX_INTERNAL.  Fix off-by-one error
	  in assert to check length of interface name.  Add error message
	  if interface with this name already exists.
	  (if_delete_retain) New function to delete an interface without
	  removing from iflist and freeing the structure.
	  (if_delete) Implement with help of if_delete_retain.
	  (ifindex2ifname) Reimplement using if_lookup_by_index.
	  (ifname2ifindex) New function to complement ifindex2ifname.
	  (interface) The interface command should check the name length
	  and fail with a warning message if it is too long.
	  (no_interface) Fix spelling in warning message.
	  (if_nametoindex) Reimplement using if_lookup_by_name.
	  (if_indextoname, ifaddr_ipv4_lookup) Reimplement using
	  if_lookup_by_index.
	* bgp_zebra.c: (bgp_interface_delete) After deleting, set ifp->ifindex
	  to IFINDEX_INTERNAL.
	* isis_zebra.c: (isis_zebra_if_del) Call if_delete_retain instead
	  of if_delete, since it is generally not safe to remove interface
	  structures.  After deleting, set ifp->ifindex to IFINDEX_INTERNAL.
	  (zebra_interface_if_lookup) Tighten up code.
	* ospf6_zebra.c: (ospf6_zebra_if_del) Previously, this whole function
	  was commented out.  But this is not safe: we should at least update
	  the ifindex when the interface is deleted.  So the new version
	  updates the interface status and sets ifp->ifindex to
	  IFINDEX_INTERNAL.
	  (ospf6_zebra_route_update) Use if_indextoname properly.
	* ospf_vty.c: (show_ip_ospf_interface_sub) Show ifindex and interface
	  flags to help with debugging.
	* ospf_zebra.c: (ospf_interface_delete) After deleting, set ifp->ifindex
	  to IFINDEX_INTERNAL.
	  (zebra_interface_if_lookup) Make function static.  Tighten up code.
	* rip_interface.c: (rip_interface_delete) After deleting, set
	  ifp->ifindex to IFINDEX_INTERNAL.
	* ripng_interface.c: (ripng_interface_delete) After deleting, set
	  ifp->ifindex to IFINDEX_INTERNAL.
Diffstat (limited to 'ospf6d')
| -rw-r--r-- | ospf6d/ChangeLog | 9 | ||||
| -rw-r--r-- | ospf6d/ospf6_zebra.c | 28 | 
2 files changed, 28 insertions, 9 deletions
diff --git a/ospf6d/ChangeLog b/ospf6d/ChangeLog index e0a5775b..61a2e463 100644 --- a/ospf6d/ChangeLog +++ b/ospf6d/ChangeLog @@ -1,5 +1,14 @@  2005-04-02 Andrew J. Schorr <ajschorr@alumni.princeton.edu> +	* ospf6_zebra.c: (ospf6_zebra_if_del) Previously, this whole function +	  was commented out.  But this is not safe: we should at least update +	  the ifindex when the interface is deleted.  So the new version +	  updates the interface status and sets ifp->ifindex to +	  IFINDEX_INTERNAL. +	  (ospf6_zebra_route_update) Use if_indextoname properly. + +2005-04-02 Andrew J. Schorr <ajschorr@alumni.princeton.edu> +  	* ospf6_route.c: (ospf6_route_show, ospf6_route_show_detail) Protect  	  against the possibility that the string returned by if_indextoname  	  may not terminate with '\0'. diff --git a/ospf6d/ospf6_zebra.c b/ospf6d/ospf6_zebra.c index bc15dff6..1ce36298 100644 --- a/ospf6d/ospf6_zebra.c +++ b/ospf6d/ospf6_zebra.c @@ -104,16 +104,24 @@ ospf6_zebra_if_add (int command, struct zclient *zclient, zebra_size_t length)  int  ospf6_zebra_if_del (int command, struct zclient *zclient, zebra_size_t length)  { -#if 0    struct interface *ifp; -  ifp = zebra_interface_delete_read (zclient->ibuf); +  if (!(ifp = zebra_interface_state_read(zclient->ibuf))) +    return 0; + +  if (if_is_up (ifp)) +    zlog_warn ("Zebra: got delete of %s, but interface is still up", ifp->name); +    if (IS_OSPF6_DEBUG_ZEBRA (RECV))      zlog_debug ("Zebra Interface delete: %s index %d mtu %d",  		ifp->name, ifp->ifindex, ifp->mtu6); +#if 0 +  /* Why is this commented out? */    ospf6_interface_if_del (ifp);  #endif /*0*/ + +  ifp->ifindex = IFINDEX_INTERNAL;    return 0;  } @@ -348,7 +356,7 @@ static void  ospf6_zebra_route_update (int type, struct ospf6_route *request)  {    struct zapi_ipv6 api; -  char buf[64], ifname[IFNAMSIZ]; +  char buf[64];    int nhcount;    struct in6_addr **nexthops;    unsigned int *ifindexes; @@ -432,13 +440,15 @@ ospf6_zebra_route_update (int type, struct ospf6_route *request)    for (i = 0; i < nhcount; i++)      {        if (IS_OSPF6_DEBUG_ZEBRA (SEND)) -        { -          inet_ntop (AF_INET6, &request->nexthop[i].address, -                     buf, sizeof (buf)); -          if_indextoname (request->nexthop[i].ifindex, ifname); -          zlog_debug ("  nexthop: %s%%%s(%d)", buf, ifname, +	{ +	  char ifname[IFNAMSIZ]; +	  inet_ntop (AF_INET6, &request->nexthop[i].address, +		     buf, sizeof (buf)); +	  if (!if_indextoname(request->nexthop[i].ifindex, ifname)) +	    strlcpy(ifname, "unknown", sizeof(ifname)); +	  zlog_debug ("  nexthop: %s%%%.*s(%d)", buf, IFNAMSIZ, ifname,  		      request->nexthop[i].ifindex); -        } +	}        nexthops[i] = &request->nexthop[i].address;        ifindexes[i] = request->nexthop[i].ifindex;      }  | 
