aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPierre Pfister <ppfister@cisco.com>2016-08-29 06:50:09 +0000
committerGerrit Code Review <gerrit@fd.io>2016-08-29 06:50:09 +0000
commiteeecc73b8e7043185cc0ca5ea307c6fd0172cff0 (patch)
tree90b4308bd7cfd78e6ef2c700c5a2d00964229c4e
parentad1ea9bae41f1159350f1d8c9d93f1d0273d9714 (diff)
parent592a739953f13d2fe5ca5aec97c0a8ff8b6984be (diff)
Merge "[router] Support UDP protocol."
-rw-r--r--router/router/router.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/router/router/router.c b/router/router/router.c
index ee23a3d..741f34c 100644
--- a/router/router/router.c
+++ b/router/router/router.c
@@ -64,6 +64,7 @@ enum {
PROTO_IGMP4,
PROTO_OSPF2,
PROTO_TCP,
+ PROTO_UDP,
PROTO_N_TOTAL,
};
@@ -73,6 +74,7 @@ enum {
PROTO_BIT_IGMP4 = 1 << PROTO_IGMP4,
PROTO_BIT_OSPF2 = 1 << PROTO_OSPF2,
PROTO_BIT_TCP = 1 << PROTO_TCP,
+ PROTO_BIT_UDP = 1 << PROTO_UDP,
};
static char *proto_strings[PROTO_N_TOTAL] = {
@@ -81,6 +83,7 @@ static char *proto_strings[PROTO_N_TOTAL] = {
[PROTO_IGMP4] = "igmp4",
[PROTO_OSPF2] = "ospf2",
[PROTO_TCP] = "tcp",
+ [PROTO_UDP] = "udp",
};
static inline u32 parse_protos(char *proto_string)
@@ -200,6 +203,8 @@ tap_inject_func(vlib_main_t *m, vlib_node_runtime_t *node, vlib_frame_t *f,
iphdr = vlib_buffer_get_current(b0);
if (iphdr->protocol == IP_PROTOCOL_TCP)
proto_bit = PROTO_BIT_TCP;
+ else if (iphdr->protocol == IP_PROTOCOL_UDP)
+ proto_bit = PROTO_BIT_UDP;
else if (iphdr->protocol == IP_PROTOCOL_OSPF)
proto_bit = PROTO_BIT_OSPF2;
else if (iphdr->protocol == IP_PROTOCOL_IGMP)
@@ -584,6 +589,15 @@ tap_inject(vlib_main_t *m, unformat_input_t *input, vlib_cli_command_t *cmd)
return clib_error_return(0,
"tcp requires arp and icmp4");
+ if (protos & PROTO_BIT_UDP) {
+ /* Require arp, icmp4, and igmp4 for udp. */
+ if (!(protos & PROTO_BIT_ARP) ||
+ !(protos & PROTO_BIT_ICMP4) ||
+ !(protos & PROTO_BIT_IGMP4))
+ return clib_error_return(0,
+ "udp requires arp, icmp4, and igmp4");
+ }
+
err = do_tap_connect(m, name, iface, &tap);
if (err) {
if (tap != ~0)
@@ -627,6 +641,10 @@ tap_inject(vlib_main_t *m, unformat_input_t *input, vlib_cli_command_t *cmd)
ip4_register_protocol(IP_PROTOCOL_TCP,
tap_inject_classified_node.index);
+ if (protos & PROTO_BIT_UDP)
+ ip4_register_protocol(IP_PROTOCOL_UDP,
+ tap_inject_classified_node.index);
+
/* Find sw_if_index of tap associated with data plane interface. */
rm.iface_to_tap[iface] = tap;
rm.iface_to_protos[iface] = protos;