Code Review
/
samplevnf.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Fix potential core dump when closing ports at exit
[samplevnf.git]
/
VNFs
/
DPPD-PROX
/
handle_nsh.c
diff --git
a/VNFs/DPPD-PROX/handle_nsh.c
b/VNFs/DPPD-PROX/handle_nsh.c
index
65a80c3
..
6d67f99
100644
(file)
--- a/
VNFs/DPPD-PROX/handle_nsh.c
+++ b/
VNFs/DPPD-PROX/handle_nsh.c
@@
-18,6
+18,10
@@
#include <rte_ether.h>
#include <rte_ip.h>
#include <rte_udp.h>
#include <rte_ether.h>
#include <rte_ip.h>
#include <rte_udp.h>
+#include <rte_version.h>
+#if RTE_VERSION >= RTE_VERSION_NUM(19,11,0,0)
+#include <rte_vxlan.h>
+#endif
#include "vxlangpe_nsh.h"
#include "task_base.h"
#include "vxlangpe_nsh.h"
#include "task_base.h"
@@
-27,7
+31,7
@@
#include "prefetch.h"
#include "log.h"
#include "prefetch.h"
#include "log.h"
-#define VXLAN_GPE_HDR_SZ sizeof(
struct ether_hdr) + sizeof(struct ipv4_hdr) + sizeof(struct udp_hdr) + sizeof(struct
vxlan_gpe_hdr) + sizeof(struct nsh_hdr)
+#define VXLAN_GPE_HDR_SZ sizeof(
prox_rte_ether_hdr) + sizeof(prox_rte_ipv4_hdr) + sizeof(prox_rte_udp_hdr) + sizeof(prox_rte_
vxlan_gpe_hdr) + sizeof(struct nsh_hdr)
#define ETHER_NSH_TYPE 0x4F89 /* 0x894F in little endian */
#define VXLAN_GPE_NSH_TYPE 0xB612 /* 4790 in little endian */
#define VXLAN_GPE_NP 0x4
#define ETHER_NSH_TYPE 0x4F89 /* 0x894F in little endian */
#define VXLAN_GPE_NSH_TYPE 0xB612 /* 4790 in little endian */
#define VXLAN_GPE_NP 0x4
@@
-51,15
+55,15
@@
static void init_task_decap_nsh(__attribute__((unused)) struct task_base *tbase,
static inline uint8_t handle_decap_nsh(__attribute__((unused)) struct task_decap_nsh *task, struct rte_mbuf *mbuf)
{
static inline uint8_t handle_decap_nsh(__attribute__((unused)) struct task_decap_nsh *task, struct rte_mbuf *mbuf)
{
-
struct
ether_hdr *eth_hdr = NULL;
-
struct
udp_hdr *udp_hdr = NULL;
-
struct
vxlan_gpe_hdr *vxlan_gpe_hdr = NULL;
+
prox_rte_
ether_hdr *eth_hdr = NULL;
+
prox_rte_
udp_hdr *udp_hdr = NULL;
+
prox_rte_
vxlan_gpe_hdr *vxlan_gpe_hdr = NULL;
uint16_t hdr_len;
uint16_t hdr_len;
- eth_hdr = rte_pktmbuf_mtod(mbuf,
struct
ether_hdr *);
+ eth_hdr = rte_pktmbuf_mtod(mbuf,
prox_rte_
ether_hdr *);
if (eth_hdr->ether_type == ETHER_NSH_TYPE) {
/* "decapsulate" Ethernet + NSH header by moving packet pointer */
if (eth_hdr->ether_type == ETHER_NSH_TYPE) {
/* "decapsulate" Ethernet + NSH header by moving packet pointer */
- hdr_len = sizeof(
struct
ether_hdr) + sizeof(struct nsh_hdr);
+ hdr_len = sizeof(
prox_rte_
ether_hdr) + sizeof(struct nsh_hdr);
mbuf->data_len = (uint16_t)(mbuf->data_len - hdr_len);
mbuf->data_off += hdr_len;
mbuf->data_len = (uint16_t)(mbuf->data_len - hdr_len);
mbuf->data_off += hdr_len;
@@
-74,15
+78,15
@@
static inline uint8_t handle_decap_nsh(__attribute__((unused)) struct task_decap
}
/* check the UDP destination port */
}
/* check the UDP destination port */
- udp_hdr = (
struct udp_hdr *)(((unsigned char *)eth_hdr) + sizeof(struct ether_hdr) + sizeof(struct
ipv4_hdr));
+ udp_hdr = (
prox_rte_udp_hdr *)(((unsigned char *)eth_hdr) + sizeof(prox_rte_ether_hdr) + sizeof(prox_rte_
ipv4_hdr));
if (udp_hdr->dst_port != VXLAN_GPE_NSH_TYPE) {
mbuf->udata64 = 0;
return 0;
}
/* check the Next Protocol field in VxLAN-GPE header */
if (udp_hdr->dst_port != VXLAN_GPE_NSH_TYPE) {
mbuf->udata64 = 0;
return 0;
}
/* check the Next Protocol field in VxLAN-GPE header */
- vxlan_gpe_hdr = (
struct vxlan_gpe_hdr *)(((unsigned char *)eth_hdr) + sizeof(struct ether_hdr) + sizeof(struct ipv4_hdr) + sizeof(struct
udp_hdr));
- if (vxlan_gpe_hdr->
next_
proto != VXLAN_GPE_NP) {
+ vxlan_gpe_hdr = (
prox_rte_vxlan_gpe_hdr *)(((unsigned char *)eth_hdr) + sizeof(prox_rte_ether_hdr) + sizeof(prox_rte_ipv4_hdr) + sizeof(prox_rte_
udp_hdr));
+ if (vxlan_gpe_hdr->proto != VXLAN_GPE_NP) {
mbuf->udata64 = 0;
return 0;
}
mbuf->udata64 = 0;
return 0;
}
@@
-131,10
+135,10
@@
static void init_task_encap_nsh(__attribute__((unused)) struct task_base *tbase,
static inline uint8_t handle_encap_nsh(__attribute__((unused)) struct task_encap_nsh *task, struct rte_mbuf *mbuf)
{
static inline uint8_t handle_encap_nsh(__attribute__((unused)) struct task_encap_nsh *task, struct rte_mbuf *mbuf)
{
-
struct
ether_hdr *eth_hdr = NULL;
+
prox_rte_
ether_hdr *eth_hdr = NULL;
struct nsh_hdr *nsh_hdr = NULL;
struct nsh_hdr *nsh_hdr = NULL;
-
struct
udp_hdr *udp_hdr = NULL;
-
struct
vxlan_gpe_hdr *vxlan_gpe_hdr = NULL;
+
prox_rte_
udp_hdr *udp_hdr = NULL;
+
prox_rte_
vxlan_gpe_hdr *vxlan_gpe_hdr = NULL;
uint16_t hdr_len;
if (mbuf == NULL)
uint16_t hdr_len;
if (mbuf == NULL)
@@
-148,9
+152,9
@@
static inline uint8_t handle_encap_nsh(__attribute__((unused)) struct task_encap
mbuf->data_off -= mbuf->udata64;
mbuf->pkt_len = (uint32_t)(mbuf->pkt_len + mbuf->udata64);
mbuf->data_off -= mbuf->udata64;
mbuf->pkt_len = (uint32_t)(mbuf->pkt_len + mbuf->udata64);
- eth_hdr = rte_pktmbuf_mtod(mbuf,
struct
ether_hdr *);
+ eth_hdr = rte_pktmbuf_mtod(mbuf,
prox_rte_
ether_hdr *);
if (eth_hdr->ether_type == ETHER_NSH_TYPE) {
if (eth_hdr->ether_type == ETHER_NSH_TYPE) {
- nsh_hdr = (struct nsh_hdr *) (((unsigned char *)eth_hdr) + sizeof(
struct
ether_hdr));
+ nsh_hdr = (struct nsh_hdr *) (((unsigned char *)eth_hdr) + sizeof(
prox_rte_
ether_hdr));
/* decrement Service Index in NSH header */
if (nsh_hdr->sf_index > 0)
/* decrement Service Index in NSH header */
if (nsh_hdr->sf_index > 0)
@@
-162,17
+166,17
@@
static inline uint8_t handle_encap_nsh(__attribute__((unused)) struct task_encap
return 0;
/* check the UDP destination port */
return 0;
/* check the UDP destination port */
- udp_hdr = (
struct udp_hdr *)(((unsigned char *)eth_hdr) + sizeof(struct ether_hdr) + sizeof(struct
ipv4_hdr));
+ udp_hdr = (
prox_rte_udp_hdr *)(((unsigned char *)eth_hdr) + sizeof(prox_rte_ether_hdr) + sizeof(prox_rte_
ipv4_hdr));
if (udp_hdr->dst_port != VXLAN_GPE_NSH_TYPE)
return 0;
/* check the Next Protocol field in VxLAN-GPE header */
if (udp_hdr->dst_port != VXLAN_GPE_NSH_TYPE)
return 0;
/* check the Next Protocol field in VxLAN-GPE header */
- vxlan_gpe_hdr = (
struct vxlan_gpe_hdr *)(((unsigned char *)eth_hdr) + sizeof(struct ether_hdr) + sizeof(struct ipv4_hdr) + sizeof(struct
udp_hdr));
- if (vxlan_gpe_hdr->
next_
proto != VXLAN_GPE_NP)
+ vxlan_gpe_hdr = (
prox_rte_vxlan_gpe_hdr *)(((unsigned char *)eth_hdr) + sizeof(prox_rte_ether_hdr) + sizeof(prox_rte_ipv4_hdr) + sizeof(prox_rte_
udp_hdr));
+ if (vxlan_gpe_hdr->proto != VXLAN_GPE_NP)
return 0;
/* decrement Service Index in NSH header */
return 0;
/* decrement Service Index in NSH header */
- nsh_hdr = (struct nsh_hdr *)(((unsigned char *)vxlan_gpe_hdr) + sizeof(
struct
vxlan_gpe_hdr));
+ nsh_hdr = (struct nsh_hdr *)(((unsigned char *)vxlan_gpe_hdr) + sizeof(
prox_rte_
vxlan_gpe_hdr));
if (nsh_hdr->sf_index > 0)
nsh_hdr->sf_index -= 1;
}
if (nsh_hdr->sf_index > 0)
nsh_hdr->sf_index -= 1;
}