aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet
diff options
context:
space:
mode:
Diffstat (limited to 'src/vnet')
-rw-r--r--src/vnet/bfd/bfd_udp.c4
-rw-r--r--src/vnet/buffer.h14
-rw-r--r--src/vnet/dhcp/dhcp4_proxy_node.c2
-rw-r--r--src/vnet/dhcp/dhcp6_proxy_node.c2
-rw-r--r--src/vnet/ethernet/ethernet.h3
-rwxr-xr-xsrc/vnet/ethernet/node.c23
-rwxr-xr-xsrc/vnet/ip/ip4_forward.c6
-rw-r--r--src/vnet/ip/ip6_forward.c6
-rw-r--r--src/vnet/ip/ip6_neighbor.c19
-rw-r--r--src/vnet/l2/l2_bvi.h2
-rw-r--r--src/vnet/lisp-cp/control.c2
-rw-r--r--src/vnet/replication.c6
12 files changed, 36 insertions, 53 deletions
diff --git a/src/vnet/bfd/bfd_udp.c b/src/vnet/bfd/bfd_udp.c
index 346c54956fe..06b843c6e95 100644
--- a/src/vnet/bfd/bfd_udp.c
+++ b/src/vnet/bfd/bfd_udp.c
@@ -843,7 +843,7 @@ bfd_udp4_find_headers (vlib_buffer_t * b, ip4_header_t ** ip4,
udp_header_t ** udp)
{
/* sanity check first */
- const i32 start = vnet_buffer (b)->ip.start_of_ip_header;
+ const i32 start = vnet_buffer (b)->l3_hdr_offset;
if (start < 0 && start < sizeof (b->pre_data))
{
BFD_ERR ("Start of ip header is before pre_data, ignoring");
@@ -1000,7 +1000,7 @@ bfd_udp6_find_headers (vlib_buffer_t * b, ip6_header_t ** ip6,
udp_header_t ** udp)
{
/* sanity check first */
- const i32 start = vnet_buffer (b)->ip.start_of_ip_header;
+ const i32 start = vnet_buffer (b)->l3_hdr_offset;
if (start < 0 && start < sizeof (b->pre_data))
{
BFD_ERR ("Start of ip header is before pre_data, ignoring");
diff --git a/src/vnet/buffer.h b/src/vnet/buffer.h
index 9aba34da930..8647db005f4 100644
--- a/src/vnet/buffer.h
+++ b/src/vnet/buffer.h
@@ -71,7 +71,6 @@
#define VNET_BUFFER_SPAN_CLONE (1 << LOG2_VNET_BUFFER_SPAN_CLONE)
#define foreach_buffer_opaque_union_subtype \
-_(ethernet) \
_(ip) \
_(swt) \
_(l2) \
@@ -100,16 +99,12 @@ _(tcp)
typedef struct
{
u32 sw_if_index[VLIB_N_RX_TX];
+ i16 l2_hdr_offset;
+ i16 l3_hdr_offset;
+ i16 l4_hdr_offset;
union
{
- /* Ethernet. */
- struct
- {
- /* Saved value of current header by ethernet-input. */
- i32 start_of_ethernet_header;
- } ethernet;
-
/* IP4/6 buffer opaque. */
struct
{
@@ -143,9 +138,6 @@ typedef struct
u8 code;
u32 data;
} icmp;
-
- /* IP header offset from vlib_buffer.data - saved by ip*_local nodes */
- i32 start_of_ip_header;
};
} ip;
diff --git a/src/vnet/dhcp/dhcp4_proxy_node.c b/src/vnet/dhcp/dhcp4_proxy_node.c
index 26e1e65cd4c..1b59cdea0d9 100644
--- a/src/vnet/dhcp/dhcp4_proxy_node.c
+++ b/src/vnet/dhcp/dhcp4_proxy_node.c
@@ -231,7 +231,7 @@ dhcp_proxy_to_server_input (vlib_main_t * vm,
o = (dhcp_option_t *) (((uword) o) + (o->length + 2));
}
- fl = vlib_buffer_get_free_list (vm, b0->free_list_index);
+ fl = vlib_buffer_get_free_list (vm, vlib_buffer_get_free_list_index (b0));
// start write at (option*)o, some packets have padding
if (((u8 *)o - (u8 *)b0->data + VPP_DHCP_OPTION82_SIZE) > fl->n_data_bytes)
{
diff --git a/src/vnet/dhcp/dhcp6_proxy_node.c b/src/vnet/dhcp/dhcp6_proxy_node.c
index 885313a588e..e109cc4cc59 100644
--- a/src/vnet/dhcp/dhcp6_proxy_node.c
+++ b/src/vnet/dhcp/dhcp6_proxy_node.c
@@ -306,7 +306,7 @@ dhcpv6_proxy_to_server_input (vlib_main_t * vm,
copy_ip6_address(&r1->link_addr, ia0);
link_address_set:
- fl = vlib_buffer_get_free_list (vm, b0->free_list_index);
+ fl = vlib_buffer_get_free_list (vm, vlib_buffer_get_free_list_index (b0));
if ((b0->current_length+sizeof(*id1)+sizeof(*vss1)+sizeof(*cmac))
> fl->n_data_bytes)
diff --git a/src/vnet/ethernet/ethernet.h b/src/vnet/ethernet/ethernet.h
index dcc656a7dbb..2fc5b804dc3 100644
--- a/src/vnet/ethernet/ethernet.h
+++ b/src/vnet/ethernet/ethernet.h
@@ -344,8 +344,7 @@ ethernet_setup_node (vlib_main_t * vm, u32 node_index)
always_inline ethernet_header_t *
ethernet_buffer_get_header (vlib_buffer_t * b)
{
- return (void *)
- (b->data + vnet_buffer (b)->ethernet.start_of_ethernet_header);
+ return (void *) (b->data + vnet_buffer (b)->l2_hdr_offset);
}
/** Returns the number of VLAN headers in the current Ethernet frame in the
diff --git a/src/vnet/ethernet/node.c b/src/vnet/ethernet/node.c
index d9fdff48287..421d501adda 100755
--- a/src/vnet/ethernet/node.c
+++ b/src/vnet/ethernet/node.c
@@ -101,7 +101,7 @@ parse_header (ethernet_input_variant_t variant,
e0 = (void *) (b0->data + b0->current_data);
- vnet_buffer (b0)->ethernet.start_of_ethernet_header = b0->current_data;
+ vnet_buffer (b0)->l2_hdr_offset = b0->current_data;
vlib_buffer_advance (b0, sizeof (e0[0]));
@@ -205,9 +205,7 @@ identify_subint (vnet_hw_interface_t * hi,
if (!(*is_l2))
{
ethernet_header_t *e0;
- e0 =
- (void *) (b0->data +
- vnet_buffer (b0)->ethernet.start_of_ethernet_header);
+ e0 = (void *) (b0->data + vnet_buffer (b0)->l2_hdr_offset);
if (!(ethernet_address_cast (e0->dst_address)))
{
@@ -238,7 +236,7 @@ determine_next_node (ethernet_main_t * em,
{
*next0 = em->l2_next;
// record the L2 len and reset the buffer so the L2 header is preserved
- u32 eth_start = vnet_buffer (b0)->ethernet.start_of_ethernet_header;
+ u32 eth_start = vnet_buffer (b0)->l2_hdr_offset;
vnet_buffer (b0)->l2.l2_len = b0->current_data - eth_start;
ASSERT (vnet_buffer (b0)->l2.l2_len ==
ethernet_buffer_header_size (b0));
@@ -424,10 +422,8 @@ ethernet_input_inline (vlib_main_t * vm,
cached_is_l2 = is_l20 = subint0->flags & SUBINT_CONFIG_L2;
}
- vnet_buffer (b0)->ethernet.start_of_ethernet_header =
- b0->current_data;
- vnet_buffer (b1)->ethernet.start_of_ethernet_header =
- b1->current_data;
+ vnet_buffer (b0)->l2_hdr_offset = b0->current_data;
+ vnet_buffer (b1)->l2_hdr_offset = b1->current_data;
if (PREDICT_TRUE (is_l20 != 0))
{
@@ -519,9 +515,9 @@ ethernet_input_inline (vlib_main_t * vm,
{
len0 = vlib_buffer_length_in_chain (vm, b0) + b0->current_data
- - vnet_buffer (b0)->ethernet.start_of_ethernet_header;
+ - vnet_buffer (b0)->l2_hdr_offset;
len1 = vlib_buffer_length_in_chain (vm, b1) + b1->current_data
- - vnet_buffer (b1)->ethernet.start_of_ethernet_header;
+ - vnet_buffer (b1)->l2_hdr_offset;
stats_n_packets += 2;
stats_n_bytes += len0 + len1;
@@ -646,8 +642,7 @@ ethernet_input_inline (vlib_main_t * vm,
cached_is_l2 = is_l20 = subint0->flags & SUBINT_CONFIG_L2;
}
- vnet_buffer (b0)->ethernet.start_of_ethernet_header =
- b0->current_data;
+ vnet_buffer (b0)->l2_hdr_offset = b0->current_data;
if (PREDICT_TRUE (is_l20 != 0))
{
@@ -710,7 +705,7 @@ ethernet_input_inline (vlib_main_t * vm,
{
len0 = vlib_buffer_length_in_chain (vm, b0) + b0->current_data
- - vnet_buffer (b0)->ethernet.start_of_ethernet_header;
+ - vnet_buffer (b0)->l2_hdr_offset;
stats_n_packets += 1;
stats_n_bytes += len0;
diff --git a/src/vnet/ip/ip4_forward.c b/src/vnet/ip/ip4_forward.c
index 8263e01c188..b8dfa8474eb 100755
--- a/src/vnet/ip/ip4_forward.c
+++ b/src/vnet/ip/ip4_forward.c
@@ -1585,8 +1585,8 @@ ip4_local_inline (vlib_main_t * vm,
ip0 = vlib_buffer_get_current (p0);
ip1 = vlib_buffer_get_current (p1);
- vnet_buffer (p0)->ip.start_of_ip_header = p0->current_data;
- vnet_buffer (p1)->ip.start_of_ip_header = p1->current_data;
+ vnet_buffer (p0)->l3_hdr_offset = p0->current_data;
+ vnet_buffer (p1)->l3_hdr_offset = p1->current_data;
sw_if_index0 = vnet_buffer (p0)->sw_if_index[VLIB_RX];
sw_if_index1 = vnet_buffer (p1)->sw_if_index[VLIB_RX];
@@ -1788,7 +1788,7 @@ ip4_local_inline (vlib_main_t * vm,
ip0 = vlib_buffer_get_current (p0);
- vnet_buffer (p0)->ip.start_of_ip_header = p0->current_data;
+ vnet_buffer (p0)->l3_hdr_offset = p0->current_data;
sw_if_index0 = vnet_buffer (p0)->sw_if_index[VLIB_RX];
diff --git a/src/vnet/ip/ip6_forward.c b/src/vnet/ip/ip6_forward.c
index 4b574b9adbd..2b8c2bd2f7c 100644
--- a/src/vnet/ip/ip6_forward.c
+++ b/src/vnet/ip/ip6_forward.c
@@ -1362,8 +1362,8 @@ ip6_local (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame)
ip0 = vlib_buffer_get_current (p0);
ip1 = vlib_buffer_get_current (p1);
- vnet_buffer (p0)->ip.start_of_ip_header = p0->current_data;
- vnet_buffer (p1)->ip.start_of_ip_header = p1->current_data;
+ vnet_buffer (p0)->l3_hdr_offset = p0->current_data;
+ vnet_buffer (p1)->l3_hdr_offset = p1->current_data;
type0 = lm->builtin_protocol_by_ip_protocol[ip0->protocol];
type1 = lm->builtin_protocol_by_ip_protocol[ip1->protocol];
@@ -1493,7 +1493,7 @@ ip6_local (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame)
ip0 = vlib_buffer_get_current (p0);
- vnet_buffer (p0)->ip.start_of_ip_header = p0->current_data;
+ vnet_buffer (p0)->l3_hdr_offset = p0->current_data;
type0 = lm->builtin_protocol_by_ip_protocol[ip0->protocol];
next0 = lm->local_next_by_ip_protocol[ip0->protocol];
diff --git a/src/vnet/ip/ip6_neighbor.c b/src/vnet/ip/ip6_neighbor.c
index b8f6f9b10e7..68a8cbbc8d0 100644
--- a/src/vnet/ip/ip6_neighbor.c
+++ b/src/vnet/ip/ip6_neighbor.c
@@ -1479,9 +1479,8 @@ icmp6_router_solicitation (vlib_main_t * vm,
sizeof (icmp6_router_advertisement_header_t);
vlib_buffer_add_data (vm,
- p0->free_list_index,
- bi0,
- (void *) &rh,
+ vlib_buffer_get_free_list_index
+ (p0), bi0, (void *) &rh,
sizeof
(icmp6_router_advertisement_header_t));
@@ -1499,9 +1498,8 @@ icmp6_router_solicitation (vlib_main_t * vm,
eth_if0->address, 6);
vlib_buffer_add_data (vm,
- p0->free_list_index,
- bi0,
- (void *) &h,
+ vlib_buffer_get_free_list_index
+ (p0), bi0, (void *) &h,
sizeof
(icmp6_neighbor_discovery_ethernet_link_layer_address_option_t));
@@ -1525,9 +1523,8 @@ icmp6_router_solicitation (vlib_main_t * vm,
sizeof (icmp6_neighbor_discovery_mtu_option_t);
vlib_buffer_add_data (vm,
- p0->free_list_index,
- bi0,
- (void *) &h,
+ vlib_buffer_get_free_list_index
+ (p0), bi0, (void *) &h,
sizeof
(icmp6_neighbor_discovery_mtu_option_t));
}
@@ -1579,7 +1576,7 @@ icmp6_router_solicitation (vlib_main_t * vm,
payload_length += sizeof( icmp6_neighbor_discovery_prefix_information_option_t);
vlib_buffer_add_data (vm,
- p0->free_list_index,
+ vlib_buffer_get_free_list_index (p0),
bi0,
(void *)&h, sizeof(icmp6_neighbor_discovery_prefix_information_option_t));
@@ -2326,7 +2323,7 @@ ip6_neighbor_send_mldpv2_report (u32 sw_if_index)
num_addr_records++;
vlib_buffer_add_data
- (vm, b0->free_list_index, bo0,
+ (vm, vlib_buffer_get_free_list_index (b0), bo0,
(void *)&rr, sizeof(icmp6_multicast_address_record_t));
payload_length += sizeof( icmp6_multicast_address_record_t);
diff --git a/src/vnet/l2/l2_bvi.h b/src/vnet/l2/l2_bvi.h
index e21a1616443..662ec402a87 100644
--- a/src/vnet/l2/l2_bvi.h
+++ b/src/vnet/l2/l2_bvi.h
@@ -57,7 +57,7 @@ l2_to_bvi (vlib_main_t * vlib_main,
}
/* Save L2 header position which may be changed due to packet replication */
- vnet_buffer (b0)->ethernet.start_of_ethernet_header = b0->current_data;
+ vnet_buffer (b0)->l2_hdr_offset = b0->current_data;
/* Strip L2 header */
l2_len = vnet_buffer (b0)->l2.l2_len;
diff --git a/src/vnet/lisp-cp/control.c b/src/vnet/lisp-cp/control.c
index 22b5c82c7ce..d8a1372d7f0 100644
--- a/src/vnet/lisp-cp/control.c
+++ b/src/vnet/lisp-cp/control.c
@@ -3706,7 +3706,7 @@ send_map_reply (lisp_cp_main_t * lcm, u32 mi, ip_address_t * dst,
static void
find_ip_header (vlib_buffer_t * b, u8 ** ip_hdr)
{
- const i32 start = vnet_buffer (b)->ip.start_of_ip_header;
+ const i32 start = vnet_buffer (b)->l3_hdr_offset;
if (start < 0 && start < -sizeof (b->pre_data))
{
*ip_hdr = 0;
diff --git a/src/vnet/replication.c b/src/vnet/replication.c
index 1c6f28d2493..0fdca0bf13c 100644
--- a/src/vnet/replication.c
+++ b/src/vnet/replication.c
@@ -43,12 +43,12 @@ replication_prep (vlib_main_t * vm,
ctx_id = ctx - rm->contexts[thread_index];
/* Save state from vlib buffer */
- ctx->saved_free_list_index = b0->free_list_index;
+ ctx->saved_free_list_index = vlib_buffer_get_free_list_index (b0);
ctx->current_data = b0->current_data;
/* Set up vlib buffer hooks */
b0->recycle_count = ctx_id;
- b0->free_list_index = rm->recycle_list_index;
+ vlib_buffer_set_free_list_index (b0, rm->recycle_list_index);
b0->flags |= VLIB_BUFFER_RECYCLE;
/* Save feature state */
@@ -129,7 +129,7 @@ replication_recycle (vlib_main_t * vm, vlib_buffer_t * b0, u32 is_last)
* This is the last replication in the list.
* Restore original buffer free functionality.
*/
- b0->free_list_index = ctx->saved_free_list_index;
+ vlib_buffer_set_free_list_index (b0, ctx->saved_free_list_index);
b0->flags &= ~VLIB_BUFFER_RECYCLE;
/* Free context back to its pool */