2 * Copyright (c) 2016 Cisco and/or its affiliates.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at:
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
19 #include <vnet/adj/adj.h>
20 #include <vnet/tunnel/tunnel_dp.h>
22 static_always_inline void
23 adj_midchain_ipip44_fixup (vlib_main_t * vm,
24 const ip_adjacency_t * adj,
27 tunnel_encap_decap_flags_t flags;
30 flags = pointer_to_uword (adj->sub_type.midchain.fixup_data);
32 ip4 = vlib_buffer_get_current (b);
33 ip4->length = clib_host_to_net_u16 (vlib_buffer_length_in_chain (vm, b));
35 if (PREDICT_TRUE(TUNNEL_ENCAP_DECAP_FLAG_NONE == flags))
44 sum = ip_csum_update (sum, old, new, ip4_header_t, length);
45 ip4->checksum = ip_csum_fold (sum);
49 tunnel_encap_fixup_4o4 (flags, ip4 + 1, ip4);
50 ip4->checksum = ip4_header_checksum (ip4);
54 static_always_inline void
55 adj_midchain_fixup (vlib_main_t *vm,
56 const ip_adjacency_t *adj,
59 if (PREDICT_TRUE(adj->rewrite_header.flags & VNET_REWRITE_FIXUP_IP4_O_4))
60 adj_midchain_ipip44_fixup (vm, adj, b);
61 else if (adj->sub_type.midchain.fixup_func)
62 adj->sub_type.midchain.fixup_func
63 (vm, adj, b, adj->sub_type.midchain.fixup_data);