Skip to content

Commit a79536f

Browse files
committed
Use underlay prefix and two harcoded bytes for traffic isolation
Do not isolate only the ip in ipv6 encapsulated packets but also the specific subnet used by dpservice on a given node. Signed-off-by: Guvenc Gulce <[email protected]>
1 parent 5bda88f commit a79536f

File tree

4 files changed

+26
-2
lines changed

4 files changed

+26
-2
lines changed

include/dp_ipaddr.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +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 0xabcd
2425

2526
// structure for holding IPv6 addresses
2627
// this way sizeof(dp_ipv6 *) is a meaningful value and passing the pointer only is safe

include/rte_flow/dp_rte_flow_helpers.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ static const struct rte_flow_item_ipv6 dp_flow_item_ipv6_dst_mask = {
6262
.hdr.dst_addr.a = "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff",
6363
.hdr.proto = 0xff,
6464
};
65+
static const struct rte_flow_item_ipv6 dp_flow_item_ipv6_dst_pfx80_mask = {
66+
.hdr.dst_addr.a = "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00",
67+
.hdr.proto = 0xff,
68+
};
6569
#ifdef ENABLE_VIRTSVC
6670
static const struct rte_flow_item_ipv6 dp_flow_item_ipv6_dst_only_mask = {
6771
.hdr.dst_addr.a = "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff",
@@ -201,6 +205,20 @@ void dp_set_ipv6_dst_flow_item(struct rte_flow_item *item,
201205
item->last = NULL;
202206
}
203207

208+
static __rte_always_inline
209+
void dp_set_ipv6_dst_pfx80_flow_item(struct rte_flow_item *item,
210+
struct rte_flow_item_ipv6 *ipv6_spec,
211+
const union dp_ipv6 *dst,
212+
uint8_t proto)
213+
{
214+
dp_set_dst_ipv6(&ipv6_spec->hdr, dst);
215+
ipv6_spec->hdr.proto = proto;
216+
item->type = RTE_FLOW_ITEM_TYPE_IPV6;
217+
item->spec = ipv6_spec;
218+
item->mask = &dp_flow_item_ipv6_dst_pfx80_mask;
219+
item->last = NULL;
220+
}
221+
204222
static __rte_always_inline
205223
void dp_set_ipv4_dst_flow_item(struct rte_flow_item *item,
206224
struct rte_flow_item_ipv4 *ipv4_spec,

src/dp_ipaddr.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ void dp_generate_ul_ipv6(union dp_ipv6 *dest)
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 = dest->_ul.flags = 0;
78+
dest->_ul.flags = 0;
79+
dest->_ul.kernel = htons(DP_UNDERLAY_KERNEL_BYTES); // Use hardcoded 2-byte kernel value
7980
#ifdef ENABLE_STATIC_UNDERLAY_IP
8081
dest->_ul.random = 1;
8182
#else

src/rte_flow/dp_rte_flow_init.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,14 @@ int dp_install_isolated_mode_ipip(uint16_t port_id, uint8_t proto_id)
2727
struct rte_flow_action_queue queue_action; // #1
2828
struct rte_flow_action action[2]; // + end
2929
int action_cnt = 0;
30+
union dp_ipv6 ul_addr6;
31+
32+
ul_addr6._ul.prefix = dp_conf_get_underlay_ip()->_prefix;
33+
ul_addr6._ul.kernel = htons(DP_UNDERLAY_KERNEL_BYTES);
3034

3135
// create match pattern: IP in IPv6 tunnel packets
3236
dp_set_eth_flow_item(&pattern[pattern_cnt++], &eth_spec, htons(RTE_ETHER_TYPE_IPV6));
33-
dp_set_ipv6_flow_item(&pattern[pattern_cnt++], &ipv6_spec, proto_id);
37+
dp_set_ipv6_dst_pfx80_flow_item(&pattern[pattern_cnt++], &ipv6_spec, &ul_addr6, proto_id);
3438
dp_set_end_flow_item(&pattern[pattern_cnt++]);
3539

3640
// create flow action: allow packets to enter dp-service packet queue

0 commit comments

Comments
 (0)