Skip to content

Commit d8ddb44

Browse files
authored
Merge pull request #148 from polycube-network/pr/fix_packet_out_deadlock
polycubed: fix packet out deadlock when attaching transparent cubes
2 parents 0c26a38 + 3e71995 commit d8ddb44

2 files changed

Lines changed: 7 additions & 5 deletions

File tree

src/polycubed/src/port.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,10 @@ uint16_t Port::index() const {
4949
}
5050

5151
uint16_t Port::get_index() const {
52-
std::lock_guard<std::mutex> guard(port_mutex_);
53-
return __get_index();
52+
return port_index_;
5453
}
5554

56-
uint16_t Port::__get_index() const {
55+
uint16_t Port::calculate_index() const {
5756
// check if there is ingress-enabled transparent cube
5857
for (auto it = cubes_.rbegin(); it != cubes_.rend(); ++it) {
5958
auto index = (*it)->get_index(ProgramType::INGRESS);
@@ -230,9 +229,11 @@ void Port::update_indexes() {
230229
}
231230
}
232231

232+
port_index_ = calculate_index();
233+
233234
// CASE4: peer -> cube[N-1]
234235
if (peer_port_) {
235-
peer_port_->set_next_index(__get_index());
236+
peer_port_->set_next_index(port_index_);
236237
}
237238

238239
// egress chain: port -> cubes[0] -> ... -> cube[N -1] -> peer

src/polycubed/src/port.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,8 @@ class Port : public polycube::service::PortIface, public PeerIface {
100100
std::shared_ptr<spdlog::logger> logger;
101101

102102
private:
103-
uint16_t __get_index() const;
103+
uint16_t port_index_; // ebpf id used by other modules to call this port
104+
uint16_t calculate_index() const;
104105
};
105106

106107
} // namespace polycubed

0 commit comments

Comments
 (0)