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]);
211 SCLogDebug(
"VXLAN found unsupported Ethertype - expected IPv4, IPv6, VLAN, or ARP");
235 static int DecodeVXLANtest01 (
void)
237 uint8_t raw_vxlan[] = {
238 0x12, 0xb5, 0x12, 0xb5, 0x00, 0x3a, 0x87, 0x51,
239 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x25, 0x00,
240 0x10, 0x00, 0x00, 0x0c, 0x01, 0x00,
241 0x00, 0x51, 0x52, 0xb3, 0x54, 0xe5,
243 0x45, 0x00, 0x00, 0x1c, 0x00, 0x01, 0x00, 0x00, 0x40, 0x11,
244 0x44, 0x45, 0x0a, 0x60, 0x00, 0x0a, 0xb9, 0x1b, 0x73, 0x06,
245 0x00, 0x35, 0x30, 0x39, 0x00, 0x08, 0x98, 0xe4
274 static int DecodeVXLANtest02 (
void)
276 uint8_t raw_vxlan[] = {
277 0x12, 0xb5, 0x12, 0xb5, 0x00, 0x3a, 0x87, 0x51,
278 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x25, 0x00,
279 0x10, 0x00, 0x00, 0x0c, 0x01, 0x00,
280 0x00, 0x51, 0x52, 0xb3, 0x54, 0xe5,
282 0x45, 0x00, 0x00, 0x1c, 0x00, 0x01, 0x00, 0x00, 0x40, 0x11,
283 0x44, 0x45, 0x0a, 0x60, 0x00, 0x0a, 0xb9, 0x1b, 0x73, 0x06,
284 0x00, 0x35, 0x30, 0x39, 0x00, 0x08, 0x98, 0xe4
293 DecodeVXLANConfigPorts(
"1");
310 static int DecodeVXLANtest03(
void)
312 uint8_t raw_vxlan[] = {
313 0xc0, 0x00, 0x12, 0xb5, 0x00, 0x57, 0x00, 0x00,
314 0xff, 0x01, 0xd2, 0x0a, 0x00, 0x00, 0x0b, 0x01,
315 0xfa, 0x16, 0x3e, 0xfe, 0x55, 0x1c,
316 0xfa, 0x16, 0x3e, 0xfe, 0x57, 0xdc,
318 0x45, 0x00, 0x00, 0x39, 0xc2, 0xae, 0x40, 0x00, 0x40, 0x06, 0x7e, 0x61, 0xc0, 0xa8, 0x01,
319 0x86, 0xda, 0x5e, 0x5d, 0x22,
320 0x00, 0x50, 0xc8, 0x34, 0xaf, 0xbd, 0x02, 0x16, 0x56, 0xea, 0x3b, 0x41, 0x50, 0x18, 0x00,
321 0xee, 0xf9, 0xda, 0x00, 0x00,
322 0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x32, 0x30, 0x30, 0x20, 0x4f, 0x4b,
333 reserved-bits-check: permissive\n\
370 static int DecodeVXLANtest04(
void)
372 uint8_t raw_vxlan[] = {
373 0x12, 0xb5, 0x12, 0xb5, 0x00, 0x3a, 0x87, 0x51,
374 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x25, 0x00,
375 0x10, 0x00, 0x00, 0x0c, 0x01, 0x00,
376 0x00, 0x51, 0x52, 0xb3, 0x54, 0xe5,
378 0x45, 0x00, 0x00, 0x1c, 0x00, 0x01, 0x00, 0x00, 0x40, 0x11, 0x44, 0x45, 0x0a, 0x60, 0x00,
379 0x0a, 0xb9, 0x1b, 0x73, 0x06,
380 0x00, 0x35, 0x30, 0x39, 0x00, 0x08, 0x98, 0xe4
390 reserved-bits-check: strict\n\
427 static int DecodeVXLANtest05(
void)
429 uint8_t raw_vxlan[] = {
430 0x12, 0xb5, 0x12, 0xb5, 0x00, 0x3a, 0x87, 0x51,
431 0x88, 0x00, 0x12, 0x34, 0x00, 0x00, 0x25,
433 0x10, 0x00, 0x00, 0x0c, 0x01, 0x00,
434 0x00, 0x51, 0x52, 0xb3, 0x54, 0xe5,
436 0x45, 0x00, 0x00, 0x1c, 0x00, 0x01, 0x00, 0x00, 0x40, 0x11, 0x44, 0x45, 0x0a, 0x60, 0x00,
437 0x0a, 0xb9, 0x1b, 0x73, 0x06,
438 0x00, 0x35, 0x30, 0x39, 0x00, 0x08, 0x98, 0xe4
448 reserved-bits-check: strict\n\
481 static int DecodeVXLANtest06(
void)
483 uint8_t raw_vxlan[] = {
484 0x12, 0xb5, 0x12, 0xb5, 0x00, 0x3a, 0x87, 0x51,
485 0x88, 0x00, 0x12, 0x34, 0x00, 0x00, 0x25,
487 0x10, 0x00, 0x00, 0x0c, 0x01, 0x00,
488 0x00, 0x51, 0x52, 0xb3, 0x54, 0xe5,
490 0x45, 0x00, 0x00, 0x1c, 0x00, 0x01, 0x00, 0x00, 0x40, 0x11, 0x44, 0x45, 0x0a, 0x60, 0x00,
491 0x0a, 0xb9, 0x1b, 0x73, 0x06,
492 0x00, 0x35, 0x30, 0x39, 0x00, 0x08, 0x98, 0xe4
502 reserved-bits-check: permissive\n\
540 static int DecodeVXLANtest07(
void)
542 uint8_t raw_dns[] = {
543 0x12, 0xb5, 0x00, 0x35, 0x00, 0x24, 0xb9, 0xd7,
544 0x49, 0xa1, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x67, 0x6f,
545 0x6f, 0x67, 0x6c, 0x65, 0x03, 0x63, 0x6f, 0x6d, 0x00, 0x00, 0x1d, 0x00,