IPv6: support multi-processes, deep copy NDP packet and dispatch.

This commit is contained in:
fengbojiang(姜凤波) 2019-07-17 17:31:47 +08:00
parent c84854ee3b
commit 7cb21a2b2b
5 changed files with 57 additions and 6 deletions

View File

@ -485,6 +485,10 @@ NETINET6_SRCS+= \
#ip6_ipsec.c
#sctp6_usrreq.c
#in6_rss.c
ifndef FF_KNI
FF_HOST_SRCS+= \
ff_dpdk_kni.c
endif
endif
ifdef FF_IPFW

View File

@ -67,7 +67,7 @@
#define KNI_MBUF_MAX 2048
#define KNI_QUEUE_SIZE 2048
static int enable_kni;
int enable_kni;
static int kni_accept;
#endif
@ -848,6 +848,13 @@ protocol_filter(const void *data, uint16_t len)
if(eth_frame_type == ETHER_TYPE_ARP)
return FILTER_ARP;
#ifdef INET6
if (eth_frame_type == ETHER_TYPE_IPv6) {
return ff_kni_proto_filter(data + ETHER_HDR_LEN,
len - ETHER_HDR_LEN, eth_frame_type);
}
#endif
#ifndef FF_KNI
return FILTER_UNKNOWN;
#else
@ -855,11 +862,7 @@ protocol_filter(const void *data, uint16_t len)
return FILTER_UNKNOWN;
}
if(eth_frame_type != ETHER_TYPE_IPv4
#ifdef INET6
&& eth_frame_type != ETHER_TYPE_IPv6
#endif
)
if(eth_frame_type != ETHER_TYPE_IPv4)
return FILTER_UNKNOWN;
return ff_kni_proto_filter(data + ETHER_HDR_LEN,
@ -975,7 +978,11 @@ process_packets(uint16_t port_id, uint16_t queue_id, struct rte_mbuf **bufs,
}
enum FilterReturn filter = protocol_filter(data, len);
#ifdef INET6
if (filter == FILTER_ARP || filter == FILTER_NDP) {
#else
if (filter == FILTER_ARP) {
#endif
struct rte_mempool *mbuf_pool;
struct rte_mbuf *mbuf_clone;
if (!pkts_from_ring) {

View File

@ -26,6 +26,7 @@
#include <stdlib.h>
#include <arpa/inet.h>
#include <netinet/icmp6.h>
#include <rte_config.h>
#include <rte_ether.h>
@ -368,6 +369,21 @@ get_ipv6_hdr_len(uint8_t *proto, void *data, uint16_t len)
return ext_hdr_len;
}
static enum FilterReturn
protocol_filter_icmp6(void *data, uint16_t len)
{
if (len < sizeof(struct icmp6_hdr))
return FILTER_UNKNOWN;
const struct icmp6_hdr *hdr;
hdr = (const struct icmp6_hdr *)data;
if (hdr->icmp6_type >= ND_ROUTER_SOLICIT && hdr->icmp6_type <= ND_REDIRECT)
return FILTER_NDP;
return FILTER_UNKNOWN;
}
#endif
static enum FilterReturn
@ -409,14 +425,28 @@ protocol_filter_ip(const void *data, uint16_t len, uint16_t eth_frame_type)
switch (proto) {
case IPPROTO_TCP:
#ifdef FF_KNI
if (!enable_kni)
break;
#else
break;
#endif
return protocol_filter_tcp(next, next_len);
case IPPROTO_UDP:
#ifdef FF_KNI
if (!enable_kni)
break;
#else
break;
#endif
return protocol_filter_udp(next, next_len);
case IPPROTO_IPIP:
return protocol_filter_ip(next, next_len, ETHER_TYPE_IPv4);
#ifdef INET6
case IPPROTO_IPV6:
return protocol_filter_ip(next, next_len, ETHER_TYPE_IPv6);
case IPPROTO_ICMPV6:
return protocol_filter_icmp6(next, next_len);
#endif
}

View File

@ -31,10 +31,15 @@
#include <rte_mbuf.h>
#include <rte_mempool.h>
extern int enable_kni;
enum FilterReturn {
FILTER_UNKNOWN = -1,
FILTER_ARP = 1,
FILTER_KNI = 2,
#ifdef INET6
FILTER_NDP = 3, // Neighbor Solicitation/Advertisement, Router Solicitation/Advertisement/Redirect
#endif
};
void ff_kni_init(uint16_t nb_ports, const char *tcp_ports,

View File

@ -104,7 +104,12 @@ setip6lifetime(const char *cmd, const char *val, int s,
time_t newval;
char *ep;
#ifndef FSTACK
clock_gettime(CLOCK_MONOTONIC_FAST, &now);
#else
clock_gettime(CLOCK_MONOTONIC, &now);
#endif
newval = (time_t)strtoul(val, &ep, 0);
if (val == ep)
errx(1, "invalid %s", cmd);