[NDP] Begin to add multicast / NDP support

This commit is contained in:
Nico Schottelius 2019-02-26 15:30:47 +01:00
parent 6895a6ab34
commit 72c600d8da
5 changed files with 35 additions and 2 deletions

View file

@ -77,10 +77,11 @@
****** rfc4861
"Neighbor Solicitation messages are multicast to the solicited-node
multicast address of the target address."
****** multicasting / groups
****** DONE multicasting / groups
******* create a group ("node") that contains "all other" ports
******* create a multicast group with an ID
******* associate the "node" with the multicast group ID
***** If destination is within ff02::1:ff00:0/104, multicast
**** TODO Make switch answer icmp6 echo request for
**** TODO Make switch answer icmp echo request for
@ -156,7 +157,8 @@ user@T:~# iptables -t mangle -A PREROUTING \
- IPv4 hosts are in 10.0.4.0/24
- IPv6 in IPv4 mapped hosts are in 10.0.6.0/24
- IPv4 default router = 10.0.0.42
**** Neighbor discover protocol
- Matching on prefix & ingress port, setting multicast
**** Static mappings
- likely need table(s)
- need tcp & udp translation

View file

@ -89,6 +89,9 @@ class L2Controller(object):
def init_ndp(self):
""" initialise neighbor discovery protocol"""
# https://en.wikipedia.org/wiki/Solicited-node_multicast_address
ndp_prefix = "ff02::1:ff00:0/104"
all_ports = range(1,5)
# create multicast nodes
for rid in range(1,5):
@ -101,6 +104,12 @@ class L2Controller(object):
self.controller.mc_node_associate(g_handle, n_handle)
self.controller.table_clear("ndp")
for port in all_ports:
self.controller.table_add("ndp", "multicast_pkg", [ndp_prefix, port], [str(port)])
def init_boilerplate(self, sw_name):
self.topo = Topology(db="topology.db")
self.sw_name = sw_name

View file

@ -9,6 +9,7 @@ typedef bit<48> mac_addr_t;
typedef bit<32> ipv4_addr_t;
typedef bit<128> ipv6_addr_t;
typedef bit<9> port_t;
typedef bit<16> mcast_t;
const bit<16> TYPE_IPV4 = 0x0800;

View file

@ -9,5 +9,6 @@
#define THE_ANSWER_TO_LIFE_THE_UNIVERSE_AND_EVERYTHING 42 /* Important constant */
#define ROUTING_TABLE_SIZE 64 /* maximum routes per protocol */
#define ADDRESS_TABLE_SIZE 64 /* maximum number of addresses per protocol */
#define NDP_TABLE_SIZE 64 /* maximum number of multicast groups */
#endif

View file

@ -21,6 +21,26 @@ control MyIngress(inout headers hdr,
clone3(CloneType.I2E, 100, meta);
}
/********************** NDP support ***********************************/
/* map port to group */
action multicast_pkg(mcast_t mcast_grp) {
standard_metadata.mcast_grp = mcast_grp;
}
table ndp {
key = {
hdr.ipv6.dst_addr: lpm;
standard_metadata.ingress_port : exact;
}
actions = {
multicast_pkg;
NoAction;
}
size = NDP_TABLE_SIZE;
default_action = NoAction;
}
/********************** ADDRESS TABLES ***********************************/
action icmp6_answer() {