summaryrefslogtreecommitdiff
path: root/service/src
diff options
context:
space:
mode:
authorsongyanchao <[email protected]>2024-04-14 13:24:41 +0800
committersongyanchao <[email protected]>2024-04-17 02:23:06 +0000
commit5a83f0d644a8564791c531d82a79e1aa4899f882 (patch)
tree5093a72b84233bd58baad5480edcdc61feab2f83 /service/src
parent0077eda5753ba103b891a3e91b3816e6d772c966 (diff)
🐞 fix: Constructed the source port for VXLAN encapsulation.
Constructed the source port for VXLAN encapsulation.
Diffstat (limited to 'service/src')
-rw-r--r--service/src/node_etherfabric.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/service/src/node_etherfabric.c b/service/src/node_etherfabric.c
index 0a959f4..60c2276 100644
--- a/service/src/node_etherfabric.c
+++ b/service/src/node_etherfabric.c
@@ -657,6 +657,15 @@ static struct rte_node_register ef_ingress_node_base = {
RTE_NODE_REGISTER(ef_ingress_node_base);
+/* Generate the source port for VXLAN encapsulation, rfc7348 */
+static inline uint16_t generate_vxlan_src_port(struct rte_mbuf * mbuf)
+{
+ uint16_t min = 49152;
+ uint16_t range = 65535 - 49152 + 1;
+
+ return min + (uint16_t)(mbuf->hash.usr % range);
+}
+
/* Fill Ether IPv4 Udp Vxlan hdr for the constructed packet */
static inline int vxlan_encap_constructed_pkt(struct rte_mbuf * mbuf, struct mrb_metadata * mrb_meta,
struct ef_peer * ef_peer_item, struct mr_dev_desc * dev_desc)
@@ -682,7 +691,7 @@ static inline int vxlan_encap_constructed_pkt(struct rte_mbuf * mbuf, struct mrb
/* TODO: the source port need to be fill with the hash of inner 2-tuple or 4-tuple,
* ignore the udp checksum */
- p_udp_hdr->src_port = htons(4789);
+ p_udp_hdr->src_port = htons(generate_vxlan_src_port(mbuf));
p_udp_hdr->dst_port = htons(4789);
p_udp_hdr->dgram_len = htons(rte_pktmbuf_pkt_len(mbuf));
p_udp_hdr->dgram_cksum = 0;