From 8cd5bd8e34eb72ee5dccc2fb0733db9da03af5c8 Mon Sep 17 00:00:00 2001 From: Zhiyong Yang Date: Tue, 28 May 2019 00:38:11 -0400 Subject: snap_input: simplify code using existing functions Change-Id: Ia0cadebab8b800e34e9574601cdebee5ca90cc6a Signed-off-by: Zhiyong Yang --- src/vnet/snap/node.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/vnet/snap/node.c b/src/vnet/snap/node.c index 884ff32444b..9baa75002cb 100644 --- a/src/vnet/snap/node.c +++ b/src/vnet/snap/node.c @@ -128,8 +128,8 @@ snap_input (vlib_main_t * vm, b0 = vlib_get_buffer (vm, bi0); b1 = vlib_get_buffer (vm, bi1); - h0 = (void *) (b0->data + b0->current_data); - h1 = (void *) (b1->data + b1->current_data); + h0 = vlib_buffer_get_current (b0); + h1 = vlib_buffer_get_current (b1); oui0 = snap_header_get_oui (h0); oui1 = snap_header_get_oui (h1); @@ -140,11 +140,8 @@ snap_input (vlib_main_t * vm, len0 = sizeof (h0[0]) - (is_ethernet0 ? sizeof (h0->protocol) : 0); len1 = sizeof (h1[0]) - (is_ethernet1 ? sizeof (h1->protocol) : 0); - b0->current_data += len0; - b1->current_data += len1; - - b0->current_length -= len0; - b1->current_length -= len1; + vlib_buffer_advance (b0, len0); + vlib_buffer_advance (b1, len1); pi0 = snap_get_protocol_info (sm, h0); pi1 = snap_get_protocol_info (sm, h1); @@ -216,7 +213,7 @@ snap_input (vlib_main_t * vm, b0 = vlib_get_buffer (vm, bi0); - h0 = (void *) (b0->data + b0->current_data); + h0 = vlib_buffer_get_current (b0); oui0 = snap_header_get_oui (h0); @@ -224,9 +221,7 @@ snap_input (vlib_main_t * vm, len0 = sizeof (h0[0]) - (is_ethernet0 ? sizeof (h0->protocol) : 0); - b0->current_data += len0; - - b0->current_length -= len0; + vlib_buffer_advance (b0, len0); pi0 = snap_get_protocol_info (sm, h0); -- cgit 1.2.3-korg