Skip to content

Commit c53deef

Browse files
committed
The commit fixed the issue when a port with index 0 adding to a allow rule
will be mistakenly regarded as wild-card rule, so even a packet from a diffrent port will be allowed passing by mistake. There are 2 changes in this commit: - update the iptables submodule pointing to the latest code base so interface parameter can be supported - change the wild-card index from 0 to 0xffff for pcn-iptables service because id 0 could be conflicting with a regular port, and recover the original failed test case. Signed-off-by: Jianwen Pi<jianwpi@gmail.com>
1 parent a9d5f85 commit c53deef

File tree

5 files changed

+6
-3
lines changed

5 files changed

+6
-3
lines changed

src/polycubed/src/base_cube.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ class BaseCube : virtual public BaseCubeIface {
8888
protected:
8989
static const int _POLYCUBE_MAX_BPF_PROGRAMS = 64;
9090
static const int _POLYCUBE_MAX_PORTS = 128;
91+
static_assert(_POLYCUBE_MAX_PORTS <= 0xffff,
92+
"_POLYCUBE_MAX_PORTS shouldn't be great than 0xffff, "
93+
"id 0xffff was used by iptables wild card index");
9194
static std::vector<std::string> cflags;
9295

9396
virtual int load(ebpf::BPF &bpf, ProgramType type) = 0;

src/services/pcn-iptables/src/Utils.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,7 @@ bool Chain::interfaceFromRulesToMap(
523523
if (interfaces.size() != 0 && dont_care_rules.size() != 0) {
524524
std::vector<uint64_t> bitVector(
525525
FROM_NRULES_TO_NELEMENTS(Iptables::max_rules_));
526-
interfaces.insert(std::pair<uint16_t, std::vector<uint64_t>>(0, bitVector));
526+
interfaces.insert(std::pair<uint16_t, std::vector<uint64_t>>(0xffff, bitVector));
527527
for (auto const &ruleNumber : dont_care_rules) {
528528
for (auto &interface : interfaces) {
529529
SET_BIT((interface.second)[ruleNumber / 63], ruleNumber % 63);

src/services/pcn-iptables/src/modules/InterfaceLookup.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ Iptables::InterfaceLookup::InterfaceLookup(
4141
: ProgramType::INGRESS) {
4242
this->type_ = type;
4343

44-
auto it = ports.find(0);
44+
auto it = ports.find(0xffff);
4545
if (it == ports.end()) {
4646
wildcard_rule_ = false;
4747
wildcard_string_ = "";

0 commit comments

Comments
 (0)