summaryrefslogtreecommitdiffstats
path: root/src/plugins/af_packet/af_packet.c
diff options
context:
space:
mode:
authorMohsin Kazmi <sykazmi@cisco.com>2023-03-07 11:07:56 +0000
committerDamjan Marion <dmarion@0xa5.net>2023-03-10 15:54:22 +0000
commit7b0d48fbb3ceebcafb18177fba02ab1a9ad4c24e (patch)
tree470661b8958c8eb70a452d93ea307b53c18eb642 /src/plugins/af_packet/af_packet.c
parent66c675e1a514a85ac56faf686fb96b63505c994f (diff)
af_packet: fix the broken functionality upon admin down
Type: fix In vpp, file descriptor handler closes the fd upon error if there is no error handling function is registered. This patch fixes the issue for af_packet interface by registering the error handling function. Errors will also be gracefully logged. Signed-off-by: Mohsin Kazmi <sykazmi@cisco.com> Change-Id: I260d780ac54ffd0199dcd6ca5b95e5afe957e968
Diffstat (limited to 'src/plugins/af_packet/af_packet.c')
-rw-r--r--src/plugins/af_packet/af_packet.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/plugins/af_packet/af_packet.c b/src/plugins/af_packet/af_packet.c
index b2f860e658d..f505fac9e2c 100644
--- a/src/plugins/af_packet/af_packet.c
+++ b/src/plugins/af_packet/af_packet.c
@@ -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;