Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use mlx5 vf as PF1 proxy #614

Merged
merged 11 commits into from
Oct 17, 2024
Prev Previous commit
Next Next commit
Assign a unique underlay address to each virtual service
  • Loading branch information
PlagueCZ committed Oct 17, 2024
commit 102e6e76109b9664e3a4ebca04a64a1803b537a5
1 change: 1 addition & 0 deletions include/dp_virtsvc.h
Original file line number Diff line number Diff line change
@@ -46,6 +46,7 @@ struct dp_virtsvc {
rte_be16_t service_port;
uint8_t proto;
uint16_t last_assigned_port;
union dp_ipv6 ul_addr;
struct rte_hash *open_ports;
struct dp_virtsvc_conn connections[DP_VIRTSVC_PORTCOUNT];
struct rte_flow *isolation_rules[DP_MAX_PF_PORTS];
3 changes: 2 additions & 1 deletion include/rte_flow/dp_rte_async_flow_isolation.h
Original file line number Diff line number Diff line change
@@ -22,7 +22,8 @@ int dp_create_virtsvc_async_isolation_templates(struct dp_port *port, uint8_t pr

struct rte_flow *dp_create_virtsvc_async_isolation_rule(uint16_t port_id, uint8_t proto_id,
const union dp_ipv6 *svc_ipv6, rte_be16_t svc_port,
struct rte_flow_template_table *template_table);
struct rte_flow_template_table *template_table,
const union dp_ipv6 *ul_addr);
#endif

#ifdef __cplusplus
7 changes: 7 additions & 0 deletions include/rte_flow/dp_rte_flow_helpers.h
Original file line number Diff line number Diff line change
@@ -68,6 +68,13 @@ static const struct rte_flow_item_ipv6 dp_flow_item_ipv6_dst_mask = {
.hdr.dst_addr = "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff",
.hdr.proto = 0xff,
};
#ifdef ENABLE_VIRTSVC
static const struct rte_flow_item_ipv6 dp_flow_item_ipv6_src_dst_mask = {
.hdr.src_addr = "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff",
.hdr.dst_addr = "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff",
.hdr.proto = 0xff,
};
#endif
#ifdef ENABLE_PF1_PROXY
static const struct rte_flow_item_ipv6 dp_flow_item_ipv6_dst_only_mask = {
.hdr.dst_addr = "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff",
4 changes: 3 additions & 1 deletion src/dp_virtsvc.c
Original file line number Diff line number Diff line change
@@ -169,6 +169,7 @@ int dp_virtsvc_init(int socket_id)
dp_virtservices_end->virtual_port = rule->virtual_port;
dp_virtservices_end->service_port = rule->service_port;
dp_copy_ipv6(&dp_virtservices_end->service_addr, &rule->service_addr);
dp_generate_ul_ipv6(&dp_virtservices_end->ul_addr);
// last_assigned_port is 0 due to zmalloc()
snprintf(hashtable_name, sizeof(hashtable_name), "virtsvc_table_%u", i);
dp_virtservices_end->open_ports = dp_create_jhash_table(DP_VIRTSVC_PORTCOUNT,
@@ -264,7 +265,8 @@ uint16_t dp_create_virtsvc_async_isolation_rules(uint16_t port_id,
service->service_port,
service->proto == IPPROTO_TCP
? tcp_template_table
: udp_template_table);
: udp_template_table,
&service->ul_addr);
if (!flow) {
DPS_LOG_ERR("Cannot create async virtsvc isolation rule", DP_LOG_VIRTSVC(service));
break;
13 changes: 2 additions & 11 deletions src/nodes/virtsvc_node.c
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@
#include "nodes/common_node.h"
#include "rte_flow/dp_rte_flow.h"

DP_NODE_REGISTER(VIRTSVC, virtsvc, DP_NODE_DEFAULT_NEXT_ONLY);
DP_NODE_REGISTER_NOINIT(VIRTSVC, virtsvc, DP_NODE_DEFAULT_NEXT_ONLY);

static uint16_t next_tx_index[DP_MAX_PORTS];

@@ -25,15 +25,6 @@ int virtsvc_node_append_tx(uint16_t port_id, const char *tx_node_name)
return dp_node_append_tx(DP_NODE_GET_SELF(virtsvc), next_tx_index, port_id, tx_node_name);
}

// runtime constant, precompute
static const union dp_ipv6 *service_ul_ip;

static int virtsvc_node_init(__rte_unused const struct rte_graph *graph, __rte_unused struct rte_node *node)
{
service_ul_ip = dp_conf_get_underlay_ip();
return DP_OK;
}

static __rte_always_inline void virtsvc_tcp_state_change(struct dp_virtsvc_conn *conn, uint8_t tcp_flags)
{
if (DP_TCP_PKT_FLAG_RST(tcp_flags)) {
@@ -102,7 +93,7 @@ static __rte_always_inline uint16_t virtsvc_request_next(struct rte_node *node,
ipv6_hdr->payload_len = htons((uint16_t)(hdr_total_len - sizeof(struct rte_ipv4_hdr)));
ipv6_hdr->proto = proto;
ipv6_hdr->hop_limits = ttl;
dp_set_src_ipv6(ipv6_hdr, service_ul_ip);
dp_set_src_ipv6(ipv6_hdr, &virtsvc->ul_addr);
dp_set_dst_ipv6(ipv6_hdr, &virtsvc->service_addr);
m->ol_flags |= RTE_MBUF_F_TX_IPV6;
m->tx_offload = 0;
6 changes: 4 additions & 2 deletions src/rte_flow/dp_rte_async_flow_isolation.c
Original file line number Diff line number Diff line change
@@ -98,7 +98,7 @@ int dp_create_virtsvc_async_isolation_templates(struct dp_port *port, uint8_t pr
.mask = &dp_flow_item_eth_mask,
},
{ .type = RTE_FLOW_ITEM_TYPE_IPV6,
.mask = &dp_flow_item_ipv6_src_mask,
.mask = &dp_flow_item_ipv6_src_dst_mask,
},
{ .type = proto_id == IPPROTO_TCP ? RTE_FLOW_ITEM_TYPE_TCP : RTE_FLOW_ITEM_TYPE_UDP,
.mask = proto_id == IPPROTO_TCP ? (const void *)&dp_flow_item_tcp_src_mask : (const void *)&dp_flow_item_udp_src_mask,
@@ -158,14 +158,16 @@ static struct rte_flow *dp_create_pf_async_isolation_rule(uint16_t port_id, uint
#ifdef ENABLE_VIRTSVC
struct rte_flow *dp_create_virtsvc_async_isolation_rule(uint16_t port_id, uint8_t proto_id,
const union dp_ipv6 *svc_ipv6, rte_be16_t svc_port,
struct rte_flow_template_table *template_table)
struct rte_flow_template_table *template_table,
const union dp_ipv6 *ul_addr)
{
const struct rte_flow_item_eth eth_spec = {
.hdr.ether_type = htons(RTE_ETHER_TYPE_IPV6),
};
const struct rte_flow_item_ipv6 ipv6_spec = {
.hdr.proto = proto_id,
.hdr.src_addr = DP_INIT_FROM_IPV6(svc_ipv6),
.hdr.dst_addr = DP_INIT_FROM_IPV6(ul_addr),
};
const struct rte_flow_item_tcp tcp_spec = {
.hdr.src_port = svc_port,