af_packet: fix the broken functionality upon admin down
[vpp.git] / src / plugins / af_packet / af_packet.c
index b2f860e..f505fac 100644 (file)
@@ -110,6 +110,26 @@ af_packet_fd_read_ready (clib_file_t * uf)
   return 0;
 }
 
+static clib_error_t *
+af_packet_fd_error (clib_file_t *uf)
+{
+  af_packet_main_t *apm = &af_packet_main;
+  clib_error_t *err = 0;
+  u64 u64;
+
+  int ret = read (uf->file_descriptor, (char *) &u64, sizeof (u64));
+
+  if (ret < 0)
+    {
+      err = clib_error_return_unix (0, "");
+      vlib_log_notice (apm->log_class, "fd %u %U", uf->file_descriptor,
+                      format_clib_error, err);
+      clib_error_free (err);
+    }
+
+  return 0;
+}
+
 static int
 is_bridge (const u8 * host_if_name)
 {
@@ -146,6 +166,7 @@ af_packet_set_rx_queues (vlib_main_t *vm, af_packet_if_t *apif)
       {
        clib_file_t template = { 0 };
        template.read_function = af_packet_fd_read_ready;
+       template.error_function = af_packet_fd_error;
        template.file_descriptor = rx_queue->fd;
        template.private_data = rx_queue->queue_index;
        template.flags = UNIX_FILE_EVENT_EDGE_TRIGGERED;