Skip to content

Commit

Permalink
Drop packets destined to real0
Browse files Browse the repository at this point in the history
Summary:
Details in T184429066
tl;dr If packet is destined to vip, but if the reals aren't initialized, drop the packet, instead of sending it to empty address

Reviewed By: frankfeir

Differential Revision: D58979009

fbshipit-source-id: 7d968877365765539eb8a7e7b5772fd3f9646105
  • Loading branch information
Nikhil Dixit Limaye authored and facebook-github-bot committed Jun 25, 2024
1 parent e50d765 commit 80f8d87
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 0 deletions.
1 change: 1 addition & 0 deletions katran/lib/bpf/balancer.bpf.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ __attribute__((__always_inline__)) static inline bool get_packet_dst(
// Real ids start from 1, so we don't map the id 0 to any real. This
// is likely to happen if the ch ring for a vip is uninitialized.
increment_ch_drop_real_0();
return false;
}
}
pckt->real_index = key;
Expand Down
17 changes: 17 additions & 0 deletions katran/lib/testing/KatranGueTestFixtures.h
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,23 @@ const std::vector<::katran::PacketAttributes> gueTestFixtures = {
.expectedReturnValue = "XDP_TX",
.expectedOutputPacket = "AADerb6vAgAAAAAAht1gAAAAAC4RQPwAIwcAAAAAAAAAAAAAEzf8AAAAAAAAAAAAAAAAAAACe0MmngAu/TFFAAAmAAEAAEARrSfAqAEqCsgBBXppAbsAEm5CAIADBEQAAAAAQA=="
},
// 35
{// Ether(src="0x1", dst="0x2")/IP(src="192.168.1.1",
// dst="10.200.1.99")/TCP(sport=31337, dport=80, flags="A")/"katran test pkt"
.inputPacket = "AgAAAAAAAQAAAAAACABFAAA3AAEAAEAGrOzAqAEBCsgBY3ppAFAAAAAAAAAAAFAQIAAnggAAa2F0cmFuIHRlc3QgcGt0",
.description = "packet to TCP based v4 VIP that is not initialzed",
.expectedReturnValue = "XDP_DROP",
.expectedOutputPacket = "AgAAAAAAAQAAAAAACABFAAA3AAEAAEAGrOzAqAEBCsgBY3ppAFAAAAAAAAAAAFAQIAAnggAAa2F0cmFuIHRlc3QgcGt0"
},
// 36
{// Ether(src="0x1", dst="0x2")/IPv6(src="fc00:2::1",
// dst="fc00:1::11")/UDP(sport=31337, dport=80)/"katran test pkt"
.inputPacket = "AgAAAAAAAQAAAAAAht1gAAAAABMRQPwAAAIAAAAAAAAAAAAAAAH8AAABAAAAAAAAAAAAAAARemkAUAATUc5rYXRyYW4gdGVzdA==",
.description = "packet to UDP based v6 VIP that is not initialized",
.expectedReturnValue = "XDP_DROP",
.expectedOutputPacket = "AgAAAAAAAQAAAAAAht1gAAAAABMRQPwAAAIAAAAAAAAAAAAAAAH8AAABAAAAAAAAAAAAAAARemkAUAATUc5rYXRyYW4gdGVzdA=="
},

};

} // namespace testing
Expand Down
12 changes: 12 additions & 0 deletions katran/lib/testing/KatranTestProvision.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,18 @@ void prepareOptionalLbData(katran::KatranLb& lb) {
lb.modifyReal("10.0.0.6", kLocalReal);
}

void prepareVipUninitializedLbData(katran::KatranLb& lb) {
katran::VipKey vip;
vip.address = "10.200.1.99";
vip.port = kVipPort;
vip.proto = kTcp;
lb.addVip(vip);

vip.address = "fc00:1::11";
vip.proto = kUdp;
lb.addVip(vip);
}

void preparePerfTestingLbData(katran::KatranLb& lb) {
for (auto& dst : kReals) {
lb.addInlineDecapDst(dst);
Expand Down
2 changes: 2 additions & 0 deletions katran/lib/testing/KatranTestProvision.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ void prepareLbData(katran::KatranLb& lb);

void prepareOptionalLbData(katran::KatranLb& lb);

void prepareVipUninitializedLbData(katran::KatranLb& lb);

void preparePerfTestingLbData(katran::KatranLb& lb);
} // namespace testing
} // namespace katran
2 changes: 2 additions & 0 deletions katran/lib/testing/katran_tester.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,8 @@ void runTestsFromFixture(
katran::BpfTester& tester,
KatranTestParam& testParam) {
prepareLbData(lb);
prepareVipUninitializedLbData(lb);

tester.resetTestFixtures(testParam.testData);
auto prog_fd = lb.getKatranProgFd();
tester.setBpfProgFd(prog_fd);
Expand Down

0 comments on commit 80f8d87

Please sign in to comment.