summaryrefslogtreecommitdiffstats
path: root/src/vnet/ip/ip_path_mtu.h
blob: 2c54fcd7401e19632077f81d3109393c6bfd7120 (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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
/*
 *------------------------------------------------------------------
 * ip_path_mtu.h
 *
 * Copyright (c) 2021 Graphiant.
 * 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.
 *------------------------------------------------------------------
 */

#include <vnet/ip/ip.h>

/**
 * @brief
 * The Path MTU DPO. interposed in the forwarding chain of the host prefix.
 */
typedef struct ip_pmtu_dpo_t_
{
  /**
   * The protocol of packets using this DPO
   */
  dpo_proto_t ipm_proto;

  u8 __pad8;

  /**
   * Configured Path Mtu
   */
  u16 ipm_pmtu;

  /**
   * number of locks.
   */
  u16 ipm_locks;

  /**
   * Stacked DPO
   */
  dpo_id_t ipm_dpo;
} ip_pmtu_dpo_t;

/*
 * PMTU DPOs are accessed in the data-path so they should not straddle a cache
 * line. Align to a integer factor of a cacheline
 */
STATIC_ASSERT_SIZEOF (ip_pmtu_dpo_t, 2 * sizeof (u64));

#define foreach_ip_pmtu_flag                                                  \
  _ (ATTACHED, 0, "attached")                                                 \
  _ (REMOTE, 1, "remote")                                                     \
  _ (STALE, 2, "stale")

typedef enum ip_pmtu_flags_t_
{
#define _(a, b, c) IP_PMTU_FLAG_##a = (1 << b),
  foreach_ip_pmtu_flag
#undef _
} ip_pmtu_flags_t;

/**
 * Remote Path MTU tracking object
 */
typedef struct ip_pmtu_t_
{
  /** linkage into the FIB graph */
  fib_node_t ipt_node;

  /** Track fib entry */
  fib_node_index_t ipt_fib_entry;
  u32 ipt_sibling;
  ip_pmtu_flags_t ipt_flags;

  /** Configured MTU */
  u16 ipt_cfg_pmtu;

  /** MTU from the parent MTU */
  u16 ipt_parent_pmtu;

  /** operational MTU; the minimum value of the cfg and parent MTU */
  u16 ipt_oper_pmtu;
} ip_pmtu_t;

extern int ip_path_mtu_update (const ip_address_t *nh, u32 table_id, u16 pmtu);

typedef walk_rc_t (*ip_path_mtu_walk_t) (index_t ipti, void *ctx);

extern void ip_path_mtu_walk (ip_path_mtu_walk_t fn, void *ctx);
extern int ip_path_mtu_replace_begin (void);
extern int ip_path_mtu_replace_end (void);

extern u32 ip_pmtu_get_table_id (const ip_pmtu_t *ipt);
extern void ip_pmtu_get_ip (const ip_pmtu_t *ipt, ip_address_t *ip);

/**
 * Data-plane accessor functions
 */
extern ip_pmtu_dpo_t *ip_pmtu_dpo_pool;
static_always_inline ip_pmtu_dpo_t *
ip_pmtu_dpo_get (index_t index)
{
  return (pool_elt_at_index (ip_pmtu_dpo_pool, index));
}

extern ip_pmtu_t *ip_pmtu_pool;
static_always_inline ip_pmtu_t *
ip_path_mtu_get (index_t index)
{
  return (pool_elt_at_index (ip_pmtu_pool, index));
}

/*
 * fd.io coding-style-patch-verification: ON
 *
 * Local Variables:
 * eval: (c-set-style "gnu")
 * End:
 */