mirror of https://github.com/F-Stack/f-stack.git
set freebsd mbuf vlan information when the vlan_strip is enable && get ether_type error when the vlan_strip is disabled
This commit is contained in:
parent
58f65b59d5
commit
86d95e99f0
|
@ -50,3 +50,4 @@ ff_getsockopt_freebsd
|
|||
ff_setsockopt_freebsd
|
||||
ff_dup
|
||||
ff_dup2
|
||||
ff_mbuf_set_vlan_info
|
||||
|
|
|
@ -97,6 +97,8 @@ static int enable_kni;
|
|||
static int kni_accept;
|
||||
#endif
|
||||
|
||||
#define ETH_P_8021Q 0x8100
|
||||
|
||||
static int numa_on;
|
||||
|
||||
static unsigned idle_sleep;
|
||||
|
@ -867,11 +869,6 @@ ff_veth_input(const struct ff_dpdk_if_context *ctx, struct rte_mbuf *pkt)
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* FIXME: should we save pkt->vlan_tci
|
||||
* if (pkt->ol_flags & PKT_RX_VLAN_PKT)
|
||||
*/
|
||||
|
||||
void *data = rte_pktmbuf_mtod(pkt, void*);
|
||||
uint16_t len = rte_pktmbuf_data_len(pkt);
|
||||
|
||||
|
@ -881,6 +878,10 @@ ff_veth_input(const struct ff_dpdk_if_context *ctx, struct rte_mbuf *pkt)
|
|||
return;
|
||||
}
|
||||
|
||||
if (pkt->ol_flags & PKT_RX_VLAN_STRIPPED) {
|
||||
ff_mbuf_set_vlan_info(hdr, pkt->vlan_tci);
|
||||
}
|
||||
|
||||
struct rte_mbuf *pn = pkt->next;
|
||||
void *prev = hdr;
|
||||
while(pn != NULL) {
|
||||
|
@ -901,15 +902,23 @@ ff_veth_input(const struct ff_dpdk_if_context *ctx, struct rte_mbuf *pkt)
|
|||
}
|
||||
|
||||
static enum FilterReturn
|
||||
protocol_filter(const void *data, uint16_t len)
|
||||
protocol_filter(const struct rte_mbuf *mbuf, uint16_t len)
|
||||
{
|
||||
if(len < ETHER_HDR_LEN)
|
||||
return FILTER_UNKNOWN;
|
||||
|
||||
const struct ether_hdr *hdr;
|
||||
const struct vlan_hdr *vlanhdr;
|
||||
void *data = rte_pktmbuf_mtod(mbuf, void*);
|
||||
hdr = (const struct ether_hdr *)data;
|
||||
uint16_t ether_type = ntohs(hdr->ether_type);
|
||||
|
||||
if(ntohs(hdr->ether_type) == ETHER_TYPE_ARP)
|
||||
if (hdr->ether_type == htons(ETH_P_8021Q) && !(mbuf->ol_flags & PKT_RX_VLAN_STRIPPED)) {
|
||||
vlanhdr = (struct vlan_hdr *)(data + sizeof(struct ether_hdr));
|
||||
ether_type = ntohs(vlanhdr->eth_proto);
|
||||
}
|
||||
|
||||
if(ether_type == ETHER_TYPE_ARP)
|
||||
return FILTER_ARP;
|
||||
|
||||
#ifndef FF_KNI
|
||||
|
@ -1034,7 +1043,7 @@ process_packets(uint16_t port_id, uint16_t queue_id, struct rte_mbuf **bufs,
|
|||
}
|
||||
}
|
||||
|
||||
enum FilterReturn filter = protocol_filter(data, len);
|
||||
enum FilterReturn filter = protocol_filter(rtem, len);
|
||||
if (filter == FILTER_ARP) {
|
||||
struct rte_mempool *mbuf_pool;
|
||||
struct rte_mbuf *mbuf_clone;
|
||||
|
|
|
@ -205,7 +205,6 @@ ff_mbuf_gethdr(void *pkt, uint16_t total, void *data,
|
|||
CSUM_DATA_VALID | CSUM_PSEUDO_HDR;
|
||||
m->m_pkthdr.csum_data = 0xffff;
|
||||
}
|
||||
|
||||
return (void *)m;
|
||||
}
|
||||
|
||||
|
@ -420,3 +419,10 @@ ff_veth_softc_to_hostc(void *softc)
|
|||
return (void *)sc->host_ctx;
|
||||
}
|
||||
|
||||
void
|
||||
ff_mbuf_set_vlan_info(void *hdr, uint16_t vlan_tci) {
|
||||
struct mbuf *m = (struct mbuf *)hdr;
|
||||
m->m_pkthdr.ether_vtag = vlan_tci;
|
||||
m->m_flags |= M_VLANTAG;
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -45,5 +45,6 @@ void ff_veth_process_packet(void *arg, void *m);
|
|||
|
||||
void *ff_veth_softc_to_hostc(void *softc);
|
||||
|
||||
void ff_mbuf_set_vlan_info(void *hdr, uint16_t vlan_tci);
|
||||
|
||||
#endif /* ifndef _FSTACK_VETH_H */
|
||||
|
|
Loading…
Reference in New Issue