aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet/ip/ip4_error.h
blob: dce3dd4c1ab376015a49d79e644a2e2f2fb758b4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/*
 * Copyright (c) 2015 Cisco and/or its affiliates.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at:
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
/*
 * ip/ip4_error.h: ip4 fast path errors
 *
 * Copyright (c) 2008 Eliot Dresselhaus
 *
 * Permission is hereby granted, free of charge, to any person obtaining
 * a copy of this software and associated documentation files (the
 * "Software"), to deal in the Software without restriction, including
 * without limitation the rights to use, copy, modify, merge, publish,
 * distribute, sublicense, and/or sell copies of the Software, and to
 * permit persons to whom the Software is furnished to do so, subject to
 * the following conditions:
 *
 * The above copyright notice and this permission notice shall be
 * included in all copies or substantial portions of the Software.
 *
 *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 *  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
 *  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
 *  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 *  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */

#ifndef included_ip_ip4_error_h
#define included_ip_ip4_error_h

#define foreach_ip4_error						\
  /* Must be first. */							\
  _ (NONE, "valid ip4 packets")						\
									\
  /* Errors signalled by ip4-input */					\
  _ (TOO_SHORT, "ip4 length < 20 bytes")				\
  _ (BAD_LENGTH, "ip4 length > l2 length")				\
  _ (BAD_CHECKSUM, "bad ip4 checksum")					\
  _ (VERSION, "ip4 version != 4")					\
  _ (OPTIONS, "ip4 options present")					\
  _ (FRAGMENT_OFFSET_ONE, "ip4 fragment offset == 1")			\
  _ (TIME_EXPIRED, "ip4 ttl <= 1")					\
									\
  /* Errors signalled by ip4-rewrite. */				\
  _ (MTU_EXCEEDED, "ip4 MTU exceeded and DF set")			\
  _ (DST_LOOKUP_MISS, "ip4 destination lookup miss")			\
  _ (SRC_LOOKUP_MISS, "ip4 source lookup miss")				\
  _ (DROP, "ip4 drop")                                                  \
  _ (PUNT, "ip4 punt")                                                  \
  _ (SAME_INTERFACE, "ip4 egress interface same as ingress")            \
									\
  /* Errors signalled by ip4-local. */					\
  _ (UNKNOWN_PROTOCOL, "unknown ip protocol")				\
  _ (TCP_CHECKSUM, "bad tcp checksum")					\
  _ (UDP_CHECKSUM, "bad udp checksum")					\
  _ (UDP_LENGTH, "inconsistent udp/ip lengths")				\
									\
  /* Spoofed packets in ip4-rewrite-local */                            \
  _ (SPOOFED_LOCAL_PACKETS, "ip4 spoofed local-address packet drops")   \
                                                                        \
  /* Errors signalled by ip4-inacl */                                   \
  _ (INACL_TABLE_MISS, "input ACL table-miss drops")                    \
  _ (INACL_SESSION_DENY, "input ACL session deny drops")                \
  /* Errors singalled by ip4-outacl */                                  \
  _ (OUTACL_TABLE_MISS, "output ACL table-miss drops")                  \
  _ (OUTACL_SESSION_DENY, "output ACL session deny drops")              \
                                                                        \
  /* Errors from mfib-forward */                                         \
  _ (RPF_FAILURE, "Multicast RPF check failed")                         \
                                                                        \
  /* Errors signalled by ip4-reassembly */                              \
  _ (REASS_DUPLICATE_FRAGMENT, "duplicate/overlapping fragments")       \
  _ (REASS_LIMIT_REACHED, "drops due to concurrent reassemblies limit") \
  _ (REASS_FRAGMENT_CHAIN_TOO_LONG, "fragment chain too long (drop)")   \
  _ (REASS_NO_BUF, "out of buffers (drop)")                             \
  _ (REASS_MALFORMED_PACKET, "malformed packets")                       \
  _ (REASS_INTERNAL_ERROR, "drops due to internal reassembly error")    \
  _ (REASS_UNSUPP_IP_PROT, "unsupported ip protocol")

typedef enum
{
#define _(sym,str) IP4_ERROR_##sym,
  foreach_ip4_error
#undef _
    IP4_N_ERROR,
} ip4_error_t;

#endif /* included_ip_ip4_error_h */

/*
 * fd.io coding-style-patch-verification: ON
 *
 * Local Variables:
 * eval: (c-set-style "gnu")
 * End:
 */
n class="p">) { fib_protocol_t payload_proto; fib_node_index_t fei; mpls_label_t label; mpls_eos_bit_t eos; /* * post MPLS table alloc and the possible rea-alloc of fib entrys * the entry pointer will no longer be valid. so save its index */ payload_proto = entry->fe_prefix.fp_proto; fei = fib_entry_get_index(entry); label = *(mpls_label_t*)data; if (MPLS_LABEL_INVALID == label) { /* * removing the local label */ FOR_EACH_MPLS_EOS_BIT(eos) { fib_table_entry_delete_index(src->mpls.fesm_lfes[eos], FIB_SOURCE_SPECIAL); } fib_table_unlock(MPLS_FIB_DEFAULT_TABLE_ID, FIB_PROTOCOL_MPLS); src->mpls.fesm_label = label; } else { fib_prefix_t prefix = { .fp_proto = FIB_PROTOCOL_MPLS, .fp_label = label, }; fib_node_index_t fib_index; dpo_id_t dpo = DPO_INVALID; /* * adding a new local label. make sure the MPLS fib exists. */ if (MPLS_LABEL_INVALID == src->mpls.fesm_label) { fib_index = fib_table_find_or_create_and_lock(FIB_PROTOCOL_MPLS, MPLS_FIB_DEFAULT_TABLE_ID); } else { fib_index = mpls_fib_index_from_table_id(MPLS_FIB_DEFAULT_TABLE_ID); /* * if this is a change in label, reomve the old one first */ if (src->mpls.fesm_label != label) { FOR_EACH_MPLS_EOS_BIT(eos) { ASSERT(FIB_NODE_INDEX_INVALID != src->mpls.fesm_lfes[eos]); fib_table_entry_delete_index(src->mpls.fesm_lfes[eos], FIB_SOURCE_SPECIAL); } } } src->mpls.fesm_label = label; FOR_EACH_MPLS_EOS_BIT(eos) { prefix.fp_eos = eos; prefix.fp_payload_proto = fib_proto_to_dpo(payload_proto); fib_entry_contribute_forwarding(fei, (eos ? FIB_FORW_CHAIN_TYPE_MPLS_EOS : FIB_FORW_CHAIN_TYPE_MPLS_NON_EOS), &dpo); src->mpls.fesm_lfes[eos] = fib_table_entry_special_dpo_add(fib_index, &prefix, FIB_SOURCE_SPECIAL, FIB_ENTRY_FLAG_EXCLUSIVE, &dpo); dpo_reset(&dpo); } } } static const void * fib_entry_src_mpls_get_data (fib_entry_src_t *src, const fib_entry_t *entry) { return (&(src->mpls.fesm_label)); } static u8* fib_entry_src_mpls_format (fib_entry_src_t *src, u8* s) { return (format(s, "MPLS local-label:%d", src->mpls.fesm_label)); } const static fib_entry_src_vft_t mpls_src_vft = { .fesv_init = fib_entry_src_mpls_init, .fesv_deinit = fib_entry_src_mpls_deinit, .fesv_add = fib_entry_src_mpls_add, .fesv_remove = fib_entry_src_mpls_remove, .fesv_format = fib_entry_src_mpls_format, .fesv_set_data = fib_entry_src_mpls_set_data, .fesv_get_data = fib_entry_src_mpls_get_data, /* * .fesv_fwd_update = fib_entry_src_mpls_fwd_update, * When the forwarding for the IP entry is updated, any MPLS chains * it has created are also updated. Since the MPLS entry will have already * installed that chain/load-balance there is no need to update the netry * FIXME: later: propagate any walk to the children of the MPLS entry. for SR */ }; void fib_entry_src_mpls_register (void) { fib_entry_src_register(FIB_SOURCE_MPLS, &mpls_src_vft); }