- b0 = vlib_get_buffer (vm, bi0);
- b1 = vlib_get_buffer (vm, bi1);
- u32 adj_index0 = vnet_buffer(b0)->ip.adj_index[VLIB_TX];
- ip_adjacency_t *adj0 = ip_get_adjacency(lm, adj_index0);
- u32 adj_index1 = vnet_buffer(b1)->ip.adj_index[VLIB_TX];
- ip_adjacency_t *adj1 = ip_get_adjacency(lm, adj_index1);
-
- /* Default use the next_index from the adjacency. A HBH option rarely redirects to a different node */
- next0 = adj0->lookup_next_index;
- next1 = adj1->lookup_next_index;
-
- ip0 = vlib_buffer_get_current (b0);
- ip1 = vlib_buffer_get_current (b1);
- hbh0 = (ip6_hop_by_hop_header_t *)(ip0+1);
- hbh1 = (ip6_hop_by_hop_header_t *)(ip1+1);
- opt0 = (ip6_hop_by_hop_option_t *)(hbh0+1);
- opt1 = (ip6_hop_by_hop_option_t *)(hbh1+1);
- limit0 = (ip6_hop_by_hop_option_t *)((u8 *)hbh0 + ((hbh0->length + 1) << 3));
- limit1 = (ip6_hop_by_hop_option_t *)((u8 *)hbh1 + ((hbh1->length + 1) << 3));
-
- /*
- * Basic validity checks
- */
- if ((hbh0->length + 1) << 3 > clib_net_to_host_u16(ip0->payload_length)) {
- error0 = IP6_HOP_BY_HOP_ERROR_FORMAT;
- next0 = IP_LOOKUP_NEXT_DROP;
- goto outdual;
- }
- /* Scan the set of h-b-h options, process ones that we understand */
- error0 = ip6_scan_hbh_options(b0, ip0, hbh0, opt0, limit0, &next0);
-
- if ((hbh1->length + 1) << 3 > clib_net_to_host_u16(ip1->payload_length)) {
- error1 = IP6_HOP_BY_HOP_ERROR_FORMAT;
- next1 = IP_LOOKUP_NEXT_DROP;
- goto outdual;
- }
- /* Scan the set of h-b-h options, process ones that we understand */
- error1 = ip6_scan_hbh_options(b1,ip1,hbh1,opt1,limit1, &next1);
-
- outdual:
- /* Has the classifier flagged this buffer for special treatment? */
- if ((error0 == 0) && (vnet_buffer(b0)->l2_classify.opaque_index == OI_DECAP))
- next0 = hm->next_override;
-
- /* Has the classifier flagged this buffer for special treatment? */
- if ((error1 == 0) && (vnet_buffer(b1)->l2_classify.opaque_index == OI_DECAP))
- next1 = hm->next_override;
-
- if (PREDICT_FALSE((node->flags & VLIB_NODE_FLAG_TRACE)))
- {
- if (b0->flags & VLIB_BUFFER_IS_TRACED) {
- ip6_hop_by_hop_trace_t *t = vlib_add_trace(vm, node, b0, sizeof (*t));
- u32 trace_len = (hbh0->length + 1) << 3;
- t->next_index = next0;
- /* Capture the h-b-h option verbatim */
- trace_len = trace_len < ARRAY_LEN(t->option_data) ? trace_len : ARRAY_LEN(t->option_data);
- t->trace_len = trace_len;
- clib_memcpy(t->option_data, hbh0, trace_len);
- }
- if (b1->flags & VLIB_BUFFER_IS_TRACED) {
- ip6_hop_by_hop_trace_t *t = vlib_add_trace(vm, node, b1, sizeof (*t));
- u32 trace_len = (hbh1->length + 1) << 3;
- t->next_index = next1;
- /* Capture the h-b-h option verbatim */
- trace_len = trace_len < ARRAY_LEN(t->option_data) ? trace_len : ARRAY_LEN(t->option_data);
- t->trace_len = trace_len;
- clib_memcpy(t->option_data, hbh1, trace_len);
- }
+ b0 = vlib_get_buffer (vm, bi0);
+ b1 = vlib_get_buffer (vm, bi1);
+
+ /* Default use the next_index from the adjacency. A HBH option rarely redirects to a different node */
+ u32 adj_index0 = vnet_buffer (b0)->ip.adj_index[VLIB_TX];
+ ip_adjacency_t *adj0 = ip_get_adjacency (lm, adj_index0);
+ u32 adj_index1 = vnet_buffer (b1)->ip.adj_index[VLIB_TX];
+ ip_adjacency_t *adj1 = ip_get_adjacency (lm, adj_index1);
+
+ /* Default use the next_index from the adjacency. A HBH option rarely redirects to a different node */
+ next0 = adj0->lookup_next_index;
+ next1 = adj1->lookup_next_index;
+
+ ip0 = vlib_buffer_get_current (b0);
+ ip1 = vlib_buffer_get_current (b1);
+ hbh0 = (ip6_hop_by_hop_header_t *) (ip0 + 1);
+ hbh1 = (ip6_hop_by_hop_header_t *) (ip1 + 1);
+ opt0 = (ip6_hop_by_hop_option_t *) (hbh0 + 1);
+ opt1 = (ip6_hop_by_hop_option_t *) (hbh1 + 1);
+ limit0 =
+ (ip6_hop_by_hop_option_t *) ((u8 *) hbh0 +
+ ((hbh0->length + 1) << 3));
+ limit1 =
+ (ip6_hop_by_hop_option_t *) ((u8 *) hbh1 +
+ ((hbh1->length + 1) << 3));
+
+ /*
+ * Basic validity checks
+ */
+ if ((hbh0->length + 1) << 3 >
+ clib_net_to_host_u16 (ip0->payload_length))
+ {
+ error0 = IP6_HOP_BY_HOP_ERROR_FORMAT;
+ next0 = IP_LOOKUP_NEXT_DROP;
+ goto outdual;
+ }
+ /* Scan the set of h-b-h options, process ones that we understand */
+ error0 = ip6_scan_hbh_options (b0, ip0, hbh0, opt0, limit0, &next0);
+
+ if ((hbh1->length + 1) << 3 >
+ clib_net_to_host_u16 (ip1->payload_length))
+ {
+ error1 = IP6_HOP_BY_HOP_ERROR_FORMAT;
+ next1 = IP_LOOKUP_NEXT_DROP;
+ goto outdual;
+ }
+ /* Scan the set of h-b-h options, process ones that we understand */
+ error1 = ip6_scan_hbh_options (b1, ip1, hbh1, opt1, limit1, &next1);
+
+ outdual:
+ /* Has the classifier flagged this buffer for special treatment? */
+ if (PREDICT_FALSE
+ ((error0 == 0)
+ && (vnet_buffer (b0)->l2_classify.opaque_index & OI_DECAP)))
+ next0 = hm->next_override;
+
+ /* Has the classifier flagged this buffer for special treatment? */
+ if (PREDICT_FALSE
+ ((error1 == 0)
+ && (vnet_buffer (b1)->l2_classify.opaque_index & OI_DECAP)))
+ next1 = hm->next_override;
+
+ if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE)))
+ {
+ if (b0->flags & VLIB_BUFFER_IS_TRACED)
+ {
+ ip6_hop_by_hop_trace_t *t =
+ vlib_add_trace (vm, node, b0, sizeof (*t));
+ u32 trace_len = (hbh0->length + 1) << 3;
+ t->next_index = next0;
+ /* Capture the h-b-h option verbatim */
+ trace_len =
+ trace_len <
+ ARRAY_LEN (t->option_data) ? trace_len :
+ ARRAY_LEN (t->option_data);
+ t->trace_len = trace_len;
+ clib_memcpy (t->option_data, hbh0, trace_len);
+ }
+ if (b1->flags & VLIB_BUFFER_IS_TRACED)
+ {
+ ip6_hop_by_hop_trace_t *t =
+ vlib_add_trace (vm, node, b1, sizeof (*t));
+ u32 trace_len = (hbh1->length + 1) << 3;
+ t->next_index = next1;
+ /* Capture the h-b-h option verbatim */
+ trace_len =
+ trace_len <
+ ARRAY_LEN (t->option_data) ? trace_len :
+ ARRAY_LEN (t->option_data);
+ t->trace_len = trace_len;
+ clib_memcpy (t->option_data, hbh1, trace_len);
+ }
+
+ }
+
+ b0->error = error_node->errors[error0];
+ b1->error = error_node->errors[error1];