43 #define VXLAN_HEADER_LEN sizeof(VXLANHeader)
45 #define VXLAN_MAX_PORTS 4
46 #define VXLAN_UNSET_PORT -1
47 #define VXLAN_DEFAULT_PORT 4789
48 #define VXLAN_DEFAULT_PORT_S "4789"
55 static bool g_vxlan_enabled =
true;
56 static int g_vxlan_ports_idx = 0;
70 SCLogDebug(
"checking dest port %u against ports %d %d %d %d", dp, g_vxlan_ports[0],
71 g_vxlan_ports[1], g_vxlan_ports[2], g_vxlan_ports[3]);
73 if (g_vxlan_enabled) {
74 for (
int i = 0; i < g_vxlan_ports_idx; i++) {
78 if (g_vxlan_ports[i] == (
const int)dp)
85 static void DecodeVXLANConfigPorts(
const char *pstr)
92 g_vxlan_ports_idx = 0;
98 g_vxlan_ports[g_vxlan_ports_idx++] = (int)p->port;
109 g_vxlan_enabled =
true;
111 g_vxlan_enabled =
false;
115 if (g_vxlan_enabled) {
117 if (node && node->
val) {
118 DecodeVXLANConfigPorts(node->
val);
124 if (node && node->
val) {
125 if (strcasecmp(node->
val,
"strict") == 0) {
127 }
else if (strcasecmp(node->
val,
"permissive") == 0) {
131 "Invalid VXLAN reserved-bits-check mode '%s', using 'strict'", node->
val);
145 const uint8_t *pkt, uint32_t
len)
155 if (!PacketIncreaseCheckLayers(p)) {
160 if ((vxlanh->
flags[0] & 0x08) == 0)
163 switch (g_vxlan_reserved_check_mode) {
165 if ((vxlanh->
flags[0] & 0xF7) != 0 ||
166 vxlanh->
flags[1] != 0 ||
177 uint32_t vni = (vxlanh->
vni[0] << 16) + (vxlanh->
vni[1] << 8) + (vxlanh->
vni[2]);
210 SCLogDebug(
"VXLAN found unsupported Ethertype - expected IPv4, IPv6, VLAN, or ARP");
234 static int DecodeVXLANtest01 (
void)
236 uint8_t raw_vxlan[] = {
237 0x12, 0xb5, 0x12, 0xb5, 0x00, 0x3a, 0x87, 0x51,
238 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x25, 0x00,
239 0x10, 0x00, 0x00, 0x0c, 0x01, 0x00,
240 0x00, 0x51, 0x52, 0xb3, 0x54, 0xe5,
242 0x45, 0x00, 0x00, 0x1c, 0x00, 0x01, 0x00, 0x00, 0x40, 0x11,
243 0x44, 0x45, 0x0a, 0x60, 0x00, 0x0a, 0xb9, 0x1b, 0x73, 0x06,
244 0x00, 0x35, 0x30, 0x39, 0x00, 0x08, 0x98, 0xe4
273 static int DecodeVXLANtest02 (
void)
275 uint8_t raw_vxlan[] = {
276 0x12, 0xb5, 0x12, 0xb5, 0x00, 0x3a, 0x87, 0x51,
277 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x25, 0x00,
278 0x10, 0x00, 0x00, 0x0c, 0x01, 0x00,
279 0x00, 0x51, 0x52, 0xb3, 0x54, 0xe5,
281 0x45, 0x00, 0x00, 0x1c, 0x00, 0x01, 0x00, 0x00, 0x40, 0x11,
282 0x44, 0x45, 0x0a, 0x60, 0x00, 0x0a, 0xb9, 0x1b, 0x73, 0x06,
283 0x00, 0x35, 0x30, 0x39, 0x00, 0x08, 0x98, 0xe4
292 DecodeVXLANConfigPorts(
"1");
309 static int DecodeVXLANtest03(
void)
311 uint8_t raw_vxlan[] = {
312 0xc0, 0x00, 0x12, 0xb5, 0x00, 0x57, 0x00, 0x00,
313 0xff, 0x01, 0xd2, 0x0a, 0x00, 0x00, 0x0b, 0x01,
314 0xfa, 0x16, 0x3e, 0xfe, 0x55, 0x1c,
315 0xfa, 0x16, 0x3e, 0xfe, 0x57, 0xdc,
317 0x45, 0x00, 0x00, 0x39, 0xc2, 0xae, 0x40, 0x00, 0x40, 0x06, 0x7e, 0x61, 0xc0, 0xa8, 0x01,
318 0x86, 0xda, 0x5e, 0x5d, 0x22,
319 0x00, 0x50, 0xc8, 0x34, 0xaf, 0xbd, 0x02, 0x16, 0x56, 0xea, 0x3b, 0x41, 0x50, 0x18, 0x00,
320 0xee, 0xf9, 0xda, 0x00, 0x00,
321 0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x32, 0x30, 0x30, 0x20, 0x4f, 0x4b,
332 reserved-bits-check: permissive\n\
369 static int DecodeVXLANtest04(
void)
371 uint8_t raw_vxlan[] = {
372 0x12, 0xb5, 0x12, 0xb5, 0x00, 0x3a, 0x87, 0x51,
373 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x25, 0x00,
374 0x10, 0x00, 0x00, 0x0c, 0x01, 0x00,
375 0x00, 0x51, 0x52, 0xb3, 0x54, 0xe5,
377 0x45, 0x00, 0x00, 0x1c, 0x00, 0x01, 0x00, 0x00, 0x40, 0x11, 0x44, 0x45, 0x0a, 0x60, 0x00,
378 0x0a, 0xb9, 0x1b, 0x73, 0x06,
379 0x00, 0x35, 0x30, 0x39, 0x00, 0x08, 0x98, 0xe4
389 reserved-bits-check: strict\n\
426 static int DecodeVXLANtest05(
void)
428 uint8_t raw_vxlan[] = {
429 0x12, 0xb5, 0x12, 0xb5, 0x00, 0x3a, 0x87, 0x51,
430 0x88, 0x00, 0x12, 0x34, 0x00, 0x00, 0x25,
432 0x10, 0x00, 0x00, 0x0c, 0x01, 0x00,
433 0x00, 0x51, 0x52, 0xb3, 0x54, 0xe5,
435 0x45, 0x00, 0x00, 0x1c, 0x00, 0x01, 0x00, 0x00, 0x40, 0x11, 0x44, 0x45, 0x0a, 0x60, 0x00,
436 0x0a, 0xb9, 0x1b, 0x73, 0x06,
437 0x00, 0x35, 0x30, 0x39, 0x00, 0x08, 0x98, 0xe4
447 reserved-bits-check: strict\n\
480 static int DecodeVXLANtest06(
void)
482 uint8_t raw_vxlan[] = {
483 0x12, 0xb5, 0x12, 0xb5, 0x00, 0x3a, 0x87, 0x51,
484 0x88, 0x00, 0x12, 0x34, 0x00, 0x00, 0x25,
486 0x10, 0x00, 0x00, 0x0c, 0x01, 0x00,
487 0x00, 0x51, 0x52, 0xb3, 0x54, 0xe5,
489 0x45, 0x00, 0x00, 0x1c, 0x00, 0x01, 0x00, 0x00, 0x40, 0x11, 0x44, 0x45, 0x0a, 0x60, 0x00,
490 0x0a, 0xb9, 0x1b, 0x73, 0x06,
491 0x00, 0x35, 0x30, 0x39, 0x00, 0x08, 0x98, 0xe4
501 reserved-bits-check: permissive\n\
539 static int DecodeVXLANtest07(
void)
541 uint8_t raw_dns[] = {
542 0x12, 0xb5, 0x00, 0x35, 0x00, 0x24, 0xb9, 0xd7,
543 0x49, 0xa1, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x67, 0x6f,
544 0x6f, 0x67, 0x6c, 0x65, 0x03, 0x63, 0x6f, 0x6d, 0x00, 0x00, 0x1d, 0x00,