On Mon, 4 Jan 2016, Donald Sharp wrote:

Doesn't 'enum zebra_link_type' actually belong in lib/if.h?  instead of
lib/zebra.h?

No strong feelings either way, or objction from me.

One other thing:


diff --git a/lib/if.h b/lib/if.h
index ad85dca..ad6624d 100644
--- a/lib/if.h
+++ b/lib/if.h
@@ -101,20 +101,10 @@ struct interface

-#else
-  unsigned short hw_type;
+  /* Link-layer information and hardware address */
+  unsigned short ll_type;
   u_char hw_addr[INTERFACE_HWADDR_MAX];
   int hw_addr_len;
-#endif /* HAVE_STRUCT_SOCKADDR_DL */

--- a/lib/zclient.c
+++ b/lib/zclient.c
@@ -791,13 +791,10 @@ zebra_interface_if_set_value (struct stream *s,
struct interface *ifp)
   ifp->mtu = stream_getl (s);
   ifp->mtu6 = stream_getl (s);
   ifp->bandwidth = stream_getl (s);
-#ifdef HAVE_STRUCT_SOCKADDR_DL
-  stream_get (&ifp->sdl, s, sizeof (ifp->sdl_storage));
-#else
+  ifp->ll_type = stream_getl (s);


+  vty_out (vty, "  Type: %s%s", if_link_type_str (ifp->ll_type),
VTY_NEWLINE);


--- a/zebra/kernel_socket.c
+++ b/zebra/kernel_socket.c



@@ -532,14 +556,17 @@ ifm_read (struct if_msghdr *ifm)

(sdl_to_zebra_link_type returns the enum)

+          ifp->ll_type = sdl_to_zebra_link_type (sdl->sdl_type);

Similar.

+  ifp->ll_type = netlink_to_zebra_link_type (ifi->ifi_type);
   netlink_interface_update_hw_addr (tb, ifp);

--- a/zebra/zserv.c
+++ b/zebra/zserv.c
@@ -154,13 +154,10 @@ zserv_encode_interface (struct stream *s, struct
interface *ifp)
   stream_putl (s, ifp->mtu);
   stream_putl (s, ifp->mtu6);
   stream_putl (s, ifp->bandwidth);
-#ifdef HAVE_STRUCT_SOCKADDR_DL
-  stream_put (s, &ifp->sdl, sizeof (ifp->sdl_storage));
-#else
+  stream_putl (s, ifp->ll_type);
   stream_putl (s, ifp->hw_addr_len);
   if (ifp->hw_addr_len)
     stream_put (s, ifp->hw_addr, ifp->hw_addr_len);
-#endif /* HAVE_STRUCT_SOCKADDR_DL */

   /* Write packet size. */
   stream_putw_at (s, 0, stream_get_endp (s));

Two things:

1. ZServ is a long and ll_type an unsigned short?

2. Should the (struct interface) member be the enum? In which case, a
   little helper to use a switch to convert between the wire type and the
   enum might be good to ensure mismatches get caught.

regards,
--
Paul Jakma      [email protected]  @pjakma Key ID: 64A2FF6A
Fortune:
Once it hits the fan, the only rational choice is to sweep it up, package it,
and sell it as fertilizer.

_______________________________________________
Quagga-dev mailing list
[email protected]
https://lists.quagga.net/mailman/listinfo/quagga-dev

Reply via email to