Support per-interface packet rx redirection

Change-Id: I8bb6124efa5665053620b48d11c8160472103c29
Signed-off-by: Dave Barach <dave@barachs.net>
diff --git a/vnet/vnet/devices/af_packet/af_packet.c b/vnet/vnet/devices/af_packet/af_packet.c
index bbaabad..1b07e89 100644
--- a/vnet/vnet/devices/af_packet/af_packet.c
+++ b/vnet/vnet/devices/af_packet/af_packet.c
@@ -209,6 +209,7 @@
   apif->rx_req = rx_req;
   apif->tx_req = tx_req;
   apif->host_if_name = host_if_name;
+  apif->per_interface_next_index = ~0;
 
   {
     unix_file_t template = {0};
diff --git a/vnet/vnet/devices/af_packet/node.c b/vnet/vnet/devices/af_packet/node.c
index efe0e1c..bc0ab8c 100644
--- a/vnet/vnet/devices/af_packet/node.c
+++ b/vnet/vnet/devices/af_packet/node.c
@@ -140,6 +140,9 @@
     VLIB_BUFFER_DEFAULT_FREE_LIST_INDEX);
   u32 min_bufs = apif->rx_req->tp_frame_size / n_buffer_bytes;
 
+  if (apif->per_interface_next_index != ~0)
+      next_index = apif->per_interface_next_index;
+
   n_free_bufs = vec_len (apm->rx_buffers);
   if (PREDICT_FALSE(n_free_bufs < VLIB_FRAME_SIZE))
     {
@@ -153,7 +156,7 @@
   while ((tph->tp_status & TP_STATUS_USER) && (n_free_bufs > min_bufs))
     {
       vlib_buffer_t * b0, * first_b0 = 0;
-      u32 next0 = AF_PACKET_INPUT_NEXT_ETHERNET_INPUT;
+      u32 next0 = next_index;
 
       u32 n_left_to_next;
       vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);