Skip to content

Commit c30b16d

Browse files
committed
Ability to encode vnf_type in underlay address
1 parent 315d2ea commit c30b16d

File tree

11 files changed

+41
-15
lines changed

11 files changed

+41
-15
lines changed

docs/deployment/README.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,22 @@ For dpservice to work properly, host IPv6 address needs to set up on `lo` instea
1010

1111
This address must be in the form of a network prefix `/64`, i.e. the last 64 bits of the host address must be zero. This way the 64 bit suffix can be used for containers or VMs running on the host.
1212

13+
It is suggested that `<host-prefix>:0000::/65` is used for host itself and `<host-prefix>:8000::/65` is then assigned special role, e.g. `<host-prefix>:f000::/68` for PodIPs, `<host-prefix>:d000::/68` for dpservice, etc.
14+
1315
Dpservice will generate addresses in the range from `<host-prefix>:d000::` to `<host-prefix>:dfff::`.
1416

15-
It is suggested that `<host-prefix>:0000::/65` is used for host itself and `<host-prefix>:8000::/65` is then assigned special role, e.g. `<host-prefix>:f000::/68` for PodIPs, `<host-prefix>:d000::/68` for dpservice, etc.
17+
If meson option `-Denable_address_type=true` is used, addresses are generated based on the usage type:
18+
19+
| Use | Range |
20+
|-|-|
21+
| `<host-prefix>:d000::/80` | unused |
22+
| `<host-prefix>:d001::/80` | NICs |
23+
| `<host-prefix>:d002::/80` | VIPs |
24+
| `<host-prefix>:d003::/80` | NATGateways |
25+
| `<host-prefix>:d004::/80` | LoadBalancers |
26+
| `<host-prefix>:d005::/80` | LoadBalancer targets |
27+
| `<host-prefix>:d006::/80` | Prefixes |
28+
| `<host-prefix>:d0ff::/80` | Virtual services |
1629

1730
## Command-line tools
1831
All tool binaries are designed to be prefixed with `dpservice-` to enable the operator to simply type `dps<TAB>` for list of possible tools.

include/dp_ipaddr.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ static_assert(sizeof(rte_be64_t) * 2 == DP_IPV6_ADDR_SIZE, "DP_IPV6_ADDR_SIZE is
2121

2222
#define DP_UNDERLAY_FLAG_EXTERNALLY_GENERATED 0x80
2323
#define DP_UNDERLAY_FLAG_SECONDARY_POOL 0x40
24-
#define DP_UNDERLAY_KERNEL_BYTES 0xd000
24+
#define DP_UNDERLAY_ADDRESS_TYPE 0xd0
2525

2626
// structure for holding IPv6 addresses
2727
// this way sizeof(dp_ipv6 *) is a meaningful value and passing the pointer only is safe
@@ -37,7 +37,8 @@ union dp_ipv6 {
3737
} _nat64;
3838
struct __rte_packed {
3939
rte_be64_t prefix;
40-
rte_be16_t kernel;
40+
uint8_t type;
41+
uint8_t subtype;
4142
uint8_t flags;
4243
uint8_t random;
4344
rte_be32_t local;
@@ -167,7 +168,7 @@ int dp_ipv4_to_str(uint32_t ipv4, char *dest, int dest_len);
167168
int dp_str_to_ipv4(const char *src, uint32_t *dest);
168169
int dp_str_to_ipv6(const char *src, union dp_ipv6 *dest);
169170

170-
void dp_generate_ul_ipv6(union dp_ipv6 *dest);
171+
void dp_generate_ul_ipv6(union dp_ipv6 *dest, uint8_t addr_type);
171172

172173

173174
// structure for holding dual IP addresses

include/dp_vnf.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ struct dp_grpc_responder;
2323

2424
enum dp_vnf_type {
2525
DP_VNF_TYPE_UNDEFINED,
26-
DP_VNF_TYPE_LB_ALIAS_PFX,
27-
DP_VNF_TYPE_ALIAS_PFX,
28-
DP_VNF_TYPE_LB,
26+
DP_VNF_TYPE_INTERFACE_IP,
2927
DP_VNF_TYPE_VIP,
3028
DP_VNF_TYPE_NAT,
31-
DP_VNF_TYPE_INTERFACE_IP,
29+
DP_VNF_TYPE_LB,
30+
DP_VNF_TYPE_LB_ALIAS_PFX,
31+
DP_VNF_TYPE_ALIAS_PFX,
3232
} __rte_packed; // for 'struct dp_flow' and 'struct flow_key'
3333

3434
struct dp_vnf_prefix {

meson.build

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ endif
5656
if get_option('enable_tests')
5757
add_global_arguments('-DENABLE_PYTEST', language: ['c', 'cpp'])
5858
endif
59+
if get_option('enable_underlay_type')
60+
add_global_arguments('-DENABLE_UNDERLAY_TYPE', language: ['c', 'cpp'])
61+
endif
5962

6063
dpdk_dep = dependency('libdpdk', version: '>=21.11.0')
6164
proto_dep = dependency('protobuf')

meson_options.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,5 @@ option('compiler_suggestions', type: 'boolean', value: false, description:
1010
'Show various compiler suggestions (warnings)')
1111
option('build_dpservice_cli', type: 'boolean', value: false, description:
1212
'Enable building of dpservice-cli golang gRPC client')
13+
option('enable_underlay_type', type: 'boolean', value: false, description:
14+
'Generate underlay address with vnf_type field')

src/dp_ipaddr.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,18 @@ int dp_ipaddr_to_str(const struct dp_ip_address *addr, char *dest, int dest_len)
7070
}
7171

7272

73-
void dp_generate_ul_ipv6(union dp_ipv6 *dest)
73+
void dp_generate_ul_ipv6(union dp_ipv6 *dest, uint8_t addr_type)
7474
{
7575
static uint32_t ul_counter = 0;
7676

7777
dest->_ul.prefix = dp_conf_get_underlay_ip()->_prefix; // Use the same prefix as the host
78-
dest->_ul.kernel = htons(DP_UNDERLAY_KERNEL_BYTES); // Use hardcoded 2-byte kernel value
78+
dest->_ul.type = DP_UNDERLAY_ADDRESS_TYPE;
79+
#ifdef ENABLE_UNDERLAY_TYPE
80+
dest->_ul.subtype = addr_type;
81+
#else
82+
(void)addr_type;
83+
dest->_ul.subtype = 0;
84+
#endif
7985
dest->_ul.flags = 0;
8086
#ifdef ENABLE_STATIC_UNDERLAY_IP
8187
dest->_ul.random = 1;

src/dp_virtsvc.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,8 @@ int dp_virtsvc_init(int socket_id)
166166
dp_virtservices_end->virtual_port = rule->virtual_port;
167167
dp_virtservices_end->service_port = rule->service_port;
168168
dp_copy_ipv6(&dp_virtservices_end->service_addr, &rule->service_addr);
169-
dp_generate_ul_ipv6(&dp_virtservices_end->ul_addr);
169+
// TODO temporary, already made better in a branch (including ifdef ENABLE_UNDERLAY_TYPE)
170+
dp_generate_ul_ipv6(&dp_virtservices_end->ul_addr, 0xff);
170171
// last_assigned_port is 0 due to zmalloc()
171172
snprintf(hashtable_name, sizeof(hashtable_name), "virtsvc_table_%u", i);
172173
dp_virtservices_end->open_ports = dp_create_jhash_table(DP_VIRTSVC_PORTCOUNT,

src/grpc/dp_grpc_impl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ static int dp_create_vnf_route(union dp_ipv6 *ul_addr6 /* out */,
3030
{
3131
// if ul_addr6 already provided, try to use that one, otherwise generate it here
3232
if (dp_ipv6_match(ul_addr6, &dp_empty_ipv6))
33-
dp_generate_ul_ipv6(ul_addr6);
33+
dp_generate_ul_ipv6(ul_addr6, type);
3434
return dp_add_vnf(ul_addr6, type, port->port_id, vni, pfx_ip, prefix_len);
3535
}
3636

src/rte_flow/dp_rte_async_flow_isolation.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ static struct rte_flow *dp_create_pf_async_isolation_rule(uint16_t port_id, stru
105105
// Only allow the right IPv6 underlay prefix
106106
const union dp_ipv6 ul_addr6 = {
107107
._ul.prefix = dp_conf_get_underlay_ip()->_prefix,
108-
._ul.kernel = htons(DP_UNDERLAY_KERNEL_BYTES),
108+
._ul.type = DP_UNDERLAY_ADDRESS_TYPE,
109109
};
110110

111111
dp_set_dst_ipv6(&ipv6_spec.hdr, &ul_addr6);

src/rte_flow/dp_rte_flow_isolation.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ int dp_install_isolated_mode(uint16_t port_id)
3030
union dp_ipv6 ul_addr6;
3131

3232
ul_addr6._ul.prefix = dp_conf_get_underlay_ip()->_prefix;
33-
ul_addr6._ul.kernel = htons(DP_UNDERLAY_KERNEL_BYTES);
33+
ul_addr6._ul.type = DP_UNDERLAY_ADDRESS_TYPE;
3434

3535
// create match pattern: IP in IPv6 tunnel packets
3636
dp_set_eth_flow_item(&pattern[pattern_cnt++], &eth_spec, htons(RTE_ETHER_TYPE_IPV6));

0 commit comments

Comments
 (0)