Skip to content

Commit

Permalink
IPv6: support multi-processes, deep copy NDP packet and dispatch.
Browse files Browse the repository at this point in the history
  • Loading branch information
jfb8856606 committed Jul 17, 2019
1 parent ca915d3 commit 10b909a
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 6 deletions.
4 changes: 4 additions & 0 deletions lib/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 13 additions & 6 deletions lib/ff_dpdk_if.c
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -848,18 +848,21 @@ 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
if (!enable_kni) {
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,
Expand Down Expand Up @@ -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) {
Expand Down
30 changes: 30 additions & 0 deletions lib/ff_dpdk_kni.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

#include <stdlib.h>
#include <arpa/inet.h>
#include <netinet/icmp6.h>

#include <rte_config.h>
#include <rte_ether.h>
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
}

Expand Down
5 changes: 5 additions & 0 deletions lib/ff_dpdk_kni.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 5 additions & 0 deletions tools/ifconfig/af_inet6.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 10b909a

Please sign in to comment.