[aarch64] Fixes CLI crashes on dpaa2 platform.
[vpp.git] / src / vppinfra / unix-formats.c
index a4c81ca..eceea2d 100644 (file)
@@ -49,6 +49,7 @@
 
 #include <unistd.h>
 #include <signal.h>
+#include <grp.h>
 
 #include <time.h>
 #include <sys/socket.h>
@@ -230,6 +231,7 @@ u8 * format_sockaddr (u8 * s, va_list * args)
 {
   void * v = va_arg (*args, void *);
   struct sockaddr * sa = v;
+  static u32 local_counter;
 
   switch (sa->sa_family)
     {
@@ -242,6 +244,17 @@ u8 * format_sockaddr (u8 * s, va_list * args)
       }
       break;
 
+    case AF_LOCAL:
+      {
+        /* 
+         * There isn't anything useful to print.
+         * The unix cli world uses the output to make a node name,
+         * so we need to return a unique name. 
+         */
+        s = format (s, "local:%u", local_counter++);
+      }
+      break;
+
 #ifndef __KERNEL__
 #ifdef AF_NETLINK
     case AF_NETLINK:
@@ -699,7 +712,7 @@ u8 * format_ethernet_packet (u8 * s, va_list * args)
   struct ethhdr * h = va_arg (*args, struct ethhdr *);
   uword proto = h->h_proto;
   u8 * payload = (void *) (h + 1);
-  uword indent;
+  u32 indent;
 
   /* Check for 802.2/802.3 encapsulation. */
   if (proto < ETH_DATA_LEN)
@@ -915,4 +928,29 @@ u8 * format_ucontext_pc (u8 * s, va_list * args)
     return format (s, "%p", regs[reg_no]);
 }
 
+uword
+unformat_unix_gid (unformat_input_t * input, va_list * args)
+{
+  gid_t *gid = va_arg (*args, gid_t *);
+  struct group *grp = 0;
+  int r;
+  u8 *s;
+
+  if (unformat (input, "%d", &r))
+    {
+      grp = getgrgid (r);
+    }
+  else if (unformat (input, "%s", &s))
+    {
+      grp = getgrnam ((char *) s);
+      vec_free (s);
+    }
+  if (grp)
+    {
+      *gid = grp->gr_gid;
+      return 1;
+    }
+  return 0;
+}
+
 #endif /* __KERNEL__ */