From 3464080f986dc32b048fb98642157edde6a57819 Mon Sep 17 00:00:00 2001 From: Divakar Date: Sun, 29 Mar 2015 22:53:24 -0700 Subject: [PATCH] New MplsoverUdp destination port Start accepting the new mplsover udp destination ports allotted by IANA. We continue to accept the old and new destination ports and continue to use range of source ports closes-bug: #1420900 Change-Id: I9bff6fdafbe7e242e0a7aef582a856777879cc17 --- dp-core/vr_proto_ip.c | 2 +- include/vr_mpls.h | 20 ++++++++++++++++---- linux/vrouter_mod.c | 4 ++-- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/dp-core/vr_proto_ip.c b/dp-core/vr_proto_ip.c index 2c806ad3a..3e27903cc 100644 --- a/dp-core/vr_proto_ip.c +++ b/dp-core/vr_proto_ip.c @@ -237,7 +237,7 @@ vr_udp_input(struct vrouter *router, struct vr_packet *pkt, return 0; } - if (ntohs(udph->udp_dport) == VR_MPLS_OVER_UDP_DST_PORT) { + if (vr_mpls_udp_port(ntohs(udph->udp_dport))) { encap_type = PKT_ENCAP_MPLS; } else if (ntohs(udph->udp_dport) == VR_VXLAN_UDP_DST_PORT) { encap_type = PKT_ENCAP_VXLAN; diff --git a/include/vr_mpls.h b/include/vr_mpls.h index 2e5906384..c65829ed0 100644 --- a/include/vr_mpls.h +++ b/include/vr_mpls.h @@ -12,10 +12,12 @@ #define VR_MAX_LABELS 5120 #define VR_MPLS_STACK_BIT (0x1 << 8) -#define VR_MPLS_OVER_UDP_DST_PORT 51234 -#define VR_MPLS_OVER_UDP_SRC_PORT 51000 -#define VR_MUDP_PORT_RANGE_START 49152 -#define VR_MUDP_PORT_RANGE_END 65535 +#define VR_MPLS_OVER_UDP_OLD_DST_PORT 51234 +#define VR_MPLS_OVER_UDP_NEW_DST_PORT 6635 +#define VR_MPLS_OVER_UDP_DST_PORT VR_MPLS_OVER_UDP_OLD_DST_PORT +#define VR_MPLS_OVER_UDP_SRC_PORT 51000 +#define VR_MUDP_PORT_RANGE_START 49152 +#define VR_MUDP_PORT_RANGE_END 65535 #define VR_VXLAN_UDP_DST_PORT 4789 #define VR_VXLAN_UDP_SRC_PORT 52000 @@ -35,6 +37,16 @@ extern int vr_mpls_input(struct vrouter *, struct vr_packet *, struct vr_forwarding_md *); +static inline bool +vr_mpls_udp_port(unsigned short port) +{ + if ((port == VR_MPLS_OVER_UDP_OLD_DST_PORT) || + (port == VR_MPLS_OVER_UDP_NEW_DST_PORT)) + return true; + + return false; +} + static inline bool vr_mpls_is_label_mcast(unsigned int lbl) diff --git a/linux/vrouter_mod.c b/linux/vrouter_mod.c index 72b4ab0d6..aa8428db4 100644 --- a/linux/vrouter_mod.c +++ b/linux/vrouter_mod.c @@ -1032,7 +1032,7 @@ lh_pull_inner_headers_fast_udp(struct vr_packet *pkt, int udph = (struct vr_udp *) pkt_data(pkt); } - if (ntohs(udph->udp_dport) == VR_MPLS_OVER_UDP_DST_PORT) { + if (vr_mpls_udp_port(ntohs(udph->udp_dport))) { *encap_type = PKT_ENCAP_MPLS; /* Take into consideration, the MPLS header and 4 bytes of @@ -1730,7 +1730,7 @@ lh_pull_inner_headers(struct vr_packet *pkt, if (ip_proto == VR_IP_PROTO_UDP) { udph = (struct udphdr *)(skb->head + pkt->vp_data); udph_cksum = udph->check; - if (ntohs(udph->dest) != VR_MPLS_OVER_UDP_DST_PORT) { + if (!vr_mpls_udp_port(ntohs(udph->dest))) { /* * we assumed earlier that the packet is mpls. now correct the * assumption