Replace tap interface using general interface 67/9467/4
authorHongjun Ni <hongjun.ni@intel.com>
Fri, 17 Nov 2017 15:43:11 +0000 (23:43 +0800)
committerDamjan Marion <dmarion.lists@gmail.com>
Fri, 17 Nov 2017 10:07:40 +0000 (10:07 +0000)
Change-Id: Icd73f00162fb6aabe296c8bb6f2174ad4f6a17b7
Signed-off-by: Hongjun Ni <hongjun.ni@intel.com>
src/plugins/pppoe.am
src/plugins/pppoe/pppoe.c
src/plugins/pppoe/pppoe.h
src/plugins/pppoe/pppoe_cp.c [moved from src/plugins/pppoe/pppoe_tap.c with 71% similarity]
src/plugins/pppoe/pppoe_cp_node.c [moved from src/plugins/pppoe/pppoe_tap_node.c with 84% similarity]
test/test_pppoe.py

index 06ed60b..5db9b7a 100644 (file)
@@ -16,8 +16,8 @@ vppplugins_LTLIBRARIES += pppoe_plugin.la
 
 pppoe_plugin_la_SOURCES =      \
     pppoe/pppoe_decap.c                \
-    pppoe/pppoe_tap.c          \
-    pppoe/pppoe_tap_node.c     \
+    pppoe/pppoe_cp.c           \
+    pppoe/pppoe_cp_node.c      \
     pppoe/pppoe.c              \
     pppoe/pppoe_api.c
 
index fe0775f..499b1d7 100644 (file)
@@ -726,7 +726,7 @@ pppoe_init (vlib_main_t * vm)
                                pppoe_input_node.index);
 
   ethernet_register_input_type (vm, ETHERNET_TYPE_PPPOE_DISCOVERY,
-                               pppoe_tap_dispatch_node.index);
+                               pppoe_cp_dispatch_node.index);
 
   return 0;
 }
index b79e4ea..77bc88f 100644 (file)
@@ -73,7 +73,7 @@ typedef struct
 _(DROP, "error-drop")                  \
 _(IP4_INPUT, "ip4-input")              \
 _(IP6_INPUT, "ip6-input" )             \
-_(CP_INPUT, "pppoe-tap-dispatch" )     \
+_(CP_INPUT, "pppoe-cp-dispatch" )      \
 
 typedef enum
 {
@@ -163,7 +163,7 @@ typedef struct
   u32 *session_index_by_sw_if_index;
 
   /* used for pppoe cp path */
-  u32 tap_if_index;
+  u32 cp_if_index;
 
   /* API message ID base */
   u16 msg_id_base;
@@ -177,7 +177,7 @@ typedef struct
 extern pppoe_main_t pppoe_main;
 
 extern vlib_node_registration_t pppoe_input_node;
-extern vlib_node_registration_t pppoe_tap_dispatch_node;
+extern vlib_node_registration_t pppoe_cp_dispatch_node;
 
 typedef struct
 {
@@ -198,7 +198,7 @@ typedef struct
 {
   u8 is_add;
   u32 client_if_index;
-  u32 tap_if_index;
+  u32 cp_if_index;
 } vnet_pppoe_add_del_tap_args_t;
 
 always_inline u64
similarity index 71%
rename from src/plugins/pppoe/pppoe_tap.c
rename to src/plugins/pppoe/pppoe_cp.c
index 60cdaaf..b99bf79 100644 (file)
  */
 
 #include <pppoe/pppoe.h>
-#include <vnet/unix/tapcli.h>
 
 static clib_error_t *
-pppoe_add_del_tap_command_fn (vlib_main_t * vm,
-                             unformat_input_t * input,
-                             vlib_cli_command_t * cmd)
+pppoe_add_del_cp_command_fn (vlib_main_t * vm,
+                            unformat_input_t * input,
+                            vlib_cli_command_t * cmd)
 {
   unformat_input_t _line_input, *line_input = &_line_input;
   pppoe_main_t *pem = &pppoe_main;
   u8 is_add = 1;
-  u8 tap_if_index_set = 0;
-  u32 tap_if_index = 0;
+  u8 cp_if_index_set = 0;
+  u32 cp_if_index = 0;
   clib_error_t *error = NULL;
 
   /* Get a line of input. */
@@ -40,8 +39,8 @@ pppoe_add_del_tap_command_fn (vlib_main_t * vm,
        {
          is_add = 0;
        }
-      else if (unformat (line_input, "tap-if-index %d", &tap_if_index))
-       tap_if_index_set = 1;
+      else if (unformat (line_input, "cp-if-index %d", &cp_if_index))
+       cp_if_index_set = 1;
       else
        {
          error = clib_error_return (0, "parse error: '%U'",
@@ -50,19 +49,19 @@ pppoe_add_del_tap_command_fn (vlib_main_t * vm,
        }
     }
 
-  if (tap_if_index_set == 0)
+  if (cp_if_index_set == 0)
     {
-      error = clib_error_return (0, "tap if index not specified");
+      error = clib_error_return (0, "cp if index not specified");
       goto done;
     }
 
   if (is_add)
     {
-      pem->tap_if_index = tap_if_index;
+      pem->cp_if_index = cp_if_index;
     }
   else
     {
-      pem->tap_if_index = ~0;
+      pem->cp_if_index = ~0;
     }
 
 done:
@@ -72,11 +71,11 @@ done:
 }
 
 /* *INDENT-OFF* */
-VLIB_CLI_COMMAND (create_pppoe_tap_cmd, static) =
+VLIB_CLI_COMMAND (create_pppoe_cp_cmd, static) =
 {
-    .path = "create pppoe tap",
-    .short_help = "create pppoe tap if-name <intfc> [del]",
-    .function = pppoe_add_del_tap_command_fn,
+    .path = "create pppoe cp",
+    .short_help = "create pppoe cp if-name <intfc> [del]",
+    .function = pppoe_add_del_cp_command_fn,
 };
 /* *INDENT-ON* */
 
similarity index 84%
rename from src/plugins/pppoe/pppoe_tap_node.c
rename to src/plugins/pppoe/pppoe_cp_node.c
index 92a6a2a..c73666d 100644 (file)
 #include <vnet/ppp/packet.h>
 #include <pppoe/pppoe.h>
 
-vlib_node_registration_t pppoe_tap_dispatch_node;
+vlib_node_registration_t pppoe_cp_dispatch_node;
 
-#define foreach_pppoe_tap_next        \
+#define foreach_pppoe_cp_next        \
 _(DROP, "error-drop")                  \
-_(TUNTAP, "tuntap-tx" )                \
 _(INTERFACE, "interface-output" )      \
 
 typedef enum
 {
-#define _(s,n) PPPOE_TAP_NEXT_##s,
-  foreach_pppoe_tap_next
+#define _(s,n) PPPOE_CP_NEXT_##s,
+  foreach_pppoe_cp_next
 #undef _
-    PPPOE_TAP_N_NEXT,
-} pppoe_tap_next_t;
+    PPPOE_CP_N_NEXT,
+} pppoe_cp_next_t;
 
 typedef struct {
   u32 next_index;
   u32 sw_if_index;
-  u32 tap_if_index;
+  u32 cp_if_index;
   u8 pppoe_code;
   u16 ppp_proto;
   u32 error;
-} pppoe_tap_trace_t;
+} pppoe_cp_trace_t;
 
-static u8 * format_pppoe_tap_trace (u8 * s, va_list * args)
+static u8 * format_pppoe_cp_trace (u8 * s, va_list * args)
 {
   CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
   CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
-  pppoe_tap_trace_t * t = va_arg (*args, pppoe_tap_trace_t *);
+  pppoe_cp_trace_t * t = va_arg (*args, pppoe_cp_trace_t *);
   pppoe_main_t * pem = &pppoe_main;
 
-  if (t->sw_if_index != pem->tap_if_index)
+  if (t->sw_if_index != pem->cp_if_index)
     {
       s = format (s, "PPPoE dispatch from sw_if_index %d next %d error %d \n"
                  "  pppoe_code 0x%x  ppp_proto 0x%x",
@@ -59,16 +58,16 @@ static u8 * format_pppoe_tap_trace (u8 * s, va_list * args)
     }
   else
     {
-      s = format (s, "PPPoE dispatch from tap_if_index %d next %d error %d \n"
+      s = format (s, "PPPoE dispatch from cp_if_index %d next %d error %d \n"
                  "  pppoe_code 0x%x  ppp_proto 0x%x",
-                  t->tap_if_index, t->next_index, t->error,
+                  t->cp_if_index, t->next_index, t->error,
                  t->pppoe_code, t->ppp_proto);
     }
   return s;
 }
 
 static uword
-pppoe_tap_dispatch (vlib_main_t * vm,
+pppoe_cp_dispatch (vlib_main_t * vm,
                     vlib_node_runtime_t * node,
                     vlib_frame_t * from_frame)
 {
@@ -138,7 +137,7 @@ pppoe_tap_dispatch (vlib_main_t * vm,
           vlib_buffer_reset(b0);
           h0 = vlib_buffer_get_current (b0);
 
-          if(rx_sw_if_index0 == pem->tap_if_index)
+          if(rx_sw_if_index0 == pem->cp_if_index)
             {
              pppoe_lookup_1 (&pem->link_table, &cached_key, &cached_result,
                              h0->dst_address, 0,
@@ -152,7 +151,7 @@ pppoe_tap_dispatch (vlib_main_t * vm,
                  goto trace00;
                }
 
-              next0 = PPPOE_TAP_NEXT_INTERFACE;
+              next0 = PPPOE_CP_NEXT_INTERFACE;
               vnet_buffer(b0)->sw_if_index[VLIB_TX] = tx_sw_if_index0;
 
               /* set src mac address */
@@ -172,8 +171,8 @@ pppoe_tap_dispatch (vlib_main_t * vm,
                                   &key0, &cached_key,
                                   &bucket0, &result0);
 
-              next0 = PPPOE_TAP_NEXT_TUNTAP;
-              vnet_buffer(b0)->sw_if_index[VLIB_TX] = pem->tap_if_index;
+              next0 = PPPOE_CP_NEXT_INTERFACE;
+              vnet_buffer(b0)->sw_if_index[VLIB_TX] = pem->cp_if_index;
             }
 
          len0 = vlib_buffer_length_in_chain (vm, b0);
@@ -203,12 +202,12 @@ pppoe_tap_dispatch (vlib_main_t * vm,
 
           if (PREDICT_FALSE(b0->flags & VLIB_BUFFER_IS_TRACED))
             {
-              pppoe_tap_trace_t *tr
+              pppoe_cp_trace_t *tr
                 = vlib_add_trace (vm, node, b0, sizeof (*tr));
               tr->next_index = next0;
               tr->error = error0;
               tr->sw_if_index = tx_sw_if_index0;
-              tr->tap_if_index = pem->tap_if_index;
+              tr->cp_if_index = pem->cp_if_index;
               tr->pppoe_code = pppoe0->code;
               tr->ppp_proto = clib_net_to_host_u16(pppoe0->ppp_proto);
             }
@@ -236,21 +235,21 @@ pppoe_tap_dispatch (vlib_main_t * vm,
   return from_frame->n_vectors;
 }
 
-VLIB_REGISTER_NODE (pppoe_tap_dispatch_node) = {
-  .function = pppoe_tap_dispatch,
-  .name = "pppoe-tap-dispatch",
+VLIB_REGISTER_NODE (pppoe_cp_dispatch_node) = {
+  .function = pppoe_cp_dispatch,
+  .name = "pppoe-cp-dispatch",
   /* Takes a vector of packets. */
   .vector_size = sizeof (u32),
 
-  .n_next_nodes = PPPOE_TAP_N_NEXT,
+  .n_next_nodes = PPPOE_CP_N_NEXT,
   .next_nodes = {
-#define _(s,n) [PPPOE_TAP_NEXT_##s] = n,
-    foreach_pppoe_tap_next
+#define _(s,n) [PPPOE_CP_NEXT_##s] = n,
+    foreach_pppoe_cp_next
 #undef _
   },
 
-  .format_trace = format_pppoe_tap_trace,
+  .format_trace = format_pppoe_cp_trace,
 };
 
-VLIB_NODE_FUNCTION_MULTIARCH (pppoe_tap_dispatch_node, pppoe_tap_dispatch)
+VLIB_NODE_FUNCTION_MULTIARCH (pppoe_cp_dispatch_node, pppoe_cp_dispatch)
 
index 1d0aeff..13499a3 100644 (file)
@@ -343,7 +343,7 @@ class TestPPPoE(VppTestCase):
         # and we should still be able to use the original
         #
         try:
-            gre_if.add_vpp_config()
+            pppoe_if.add_vpp_config()
         except Exception:
             pass
         else:
@@ -400,7 +400,7 @@ class TestPPPoE(VppTestCase):
         # and we should still be able to use the original
         #
         try:
-            gre_if.remove_vpp_config()
+            pppoe_if.remove_vpp_config()
         except Exception:
             pass
         else: