Created
December 2, 2019 21:55
-
-
Save tehnerd/1b5c0ea2092d0d081b4704361b021f2e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/katran/lib/bpf/balancer_kern.c b/katran/lib/bpf/balancer_kern.c | |
index 93dca2e..99e7d45 100644 | |
--- a/katran/lib/bpf/balancer_kern.c | |
+++ b/katran/lib/bpf/balancer_kern.c | |
@@ -240,7 +240,7 @@ static inline int process_l3_headers(struct packet_description *pckt, | |
__attribute__((__always_inline__)) | |
static inline int process_encaped_pckt(void **data, void **data_end, | |
struct xdp_md *xdp, bool *is_ipv6, | |
- __u8 *protocol) { | |
+ __u8 *protocol, bool pass) { | |
int action; | |
if (*protocol == IPPROTO_IPIP) { | |
if (*is_ipv6) { | |
@@ -276,6 +276,10 @@ static inline int process_encaped_pckt(void **data, void **data_end, | |
if (action >= 0) { | |
return action; | |
} | |
+ if (pass) { | |
+ // pass packet to kernel after decapsulation | |
+ return XDP_PASS; | |
+ } | |
return recirculate(xdp); | |
} | |
#endif // INLINE_DECAP | |
@@ -306,6 +310,7 @@ static inline int process_packet(void *data, __u64 off, void *data_end, | |
#ifdef INLINE_DECAP | |
if (protocol == IPPROTO_IPIP || protocol == IPPROTO_IPV6) { | |
+ bool pass = true; | |
struct address dst_addr = {}; | |
if (is_ipv6) { | |
memcpy(dst_addr.addrv6, pckt.flow.dstv6, 16); | |
@@ -320,10 +325,11 @@ static inline int process_packet(void *data, __u64 off, void *data_end, | |
if (!data_stats) { | |
return XDP_DROP; | |
} | |
+ pass = false; | |
data_stats->v1 += 1; | |
} | |
- return process_encaped_pckt(&data, &data_end, xdp, &is_ipv6, &protocol); | |
+ return process_encaped_pckt(&data, &data_end, xdp, &is_ipv6, &protocol, pass); | |
} | |
#endif // INLINE_DECAP | |
diff --git a/katran/lib/testing/KatranOptionalTestFixtures.h b/katran/lib/testing/KatranOptionalTestFixtures.h | |
index feb7e10..f7a1f89 100644 | |
--- a/katran/lib/testing/KatranOptionalTestFixtures.h | |
+++ b/katran/lib/testing/KatranOptionalTestFixtures.h | |
@@ -112,6 +112,19 @@ const TestFixture inputOptionalTestFixtures = { | |
"AgAAAAAAAQAAAAAAht1gAAAAAEspQAEAAAAAAAAAAAAAAAAAAGT8ABQEAAAAAAAAAAAAAAABYAAAAAAjBgH8ACMHAAEAAAAAAAAAAAAC/AAAAQAAAAAAAAAAAAAAAXppAFAAAAAAAAAAAFAQIADaSAAAa2F0cmFuIHRlc3QgcGt0", | |
"ip6ip6 inline decap ttl 1. INLINE_DECAP is required" | |
}, | |
+ //15 | |
+ { | |
+ //Ether(src="0x1", dst="0x2")/IPv6(src="100::64", dst="fc00:1404::2")/IP(src="192.168.1.3", dst="10.200.1.1")/UDP(sport=31337, dport=80)/"katran test pkt" | |
+ "AgAAAAAAAQAAAAAAht1gAAAAACsEQAEAAAAAAAAAAAAAAAAAAGT8ABQEAAAAAAAAAAAAAAACRQAAKwABAABAEa1NwKgBAwrIAQF6aQBQABeX3GthdHJhbiB0ZXN0IHBrdA==", | |
+ "ip4ip6 dst is not decap VIP. INLINE_DECAP is required" | |
+ }, | |
+ //16 | |
+ { | |
+ //Ether(src="0x1", dst="0x2")/IPv6(src="100::64", dst="fc00:1404::2")/IPv6(src="fc00:2307:1::2", dst="fc00:1::1")/TCP(sport=31337, dport=80,flags="A")/"katran test pkt" | |
+ "AgAAAAAAAQAAAAAAht1gAAAAAEspQAEAAAAAAAAAAAAAAAAAAGT8ABQEAAAAAAAAAAAAAAACYAAAAAAjBkD8ACMHAAEAAAAAAAAAAAAC/AAAAQAAAAAAAAAAAAAAAXppAFAAAAAAAAAAAFAQIADaSAAAa2F0cmFuIHRlc3QgcGt0", | |
+ "ip6ip6 dst is not decap VIP. INLINE_DECAP is required" | |
+ }, | |
+ | |
}; | |
const TestFixture outputOptionalTestFixtures = { | |
@@ -185,6 +198,16 @@ const TestFixture outputOptionalTestFixtures = { | |
"AgAAAAAAAQAAAAAAht1gAAAAACMGAPwAIwcAAQAAAAAAAAAAAAL8AAABAAAAAAAAAAAAAAABemkAUAAAAAAAAAAAUBAgANpIAABrYXRyYW4gdGVzdCBwa3Q=", | |
"XDP_DROP" | |
}, | |
+ //15 | |
+ { | |
+ "AgAAAAAAAQAAAAAACABFAAArAAEAAD8Rrk3AqAEDCsgBAXppAFAAF5fca2F0cmFuIHRlc3QgcGt0", | |
+ "XDP_PASS" | |
+ }, | |
+ //16 | |
+ { | |
+ "AgAAAAAAAQAAAAAAht1gAAAAACMGP/wAIwcAAQAAAAAAAAAAAAL8AAABAAAAAAAAAAAAAAABemkAUAAAAAAAAAAAUBAgANpIAABrYXRyYW4gdGVzdCBwa3Q=", | |
+ "XDP_PASS" | |
+ }, | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment