Skip to content

Commit a89a923

Browse files
authored
Merge pull request #123 from polycube-network/pr/fix_show_parent
polycubed: show parent when attached to a netdev
2 parents 09d1bd5 + d55111d commit a89a923

3 files changed

Lines changed: 11 additions & 2 deletions

File tree

src/polycubed/src/extiface.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,5 +251,9 @@ bool ExtIface::is_used() const {
251251
return cubes_.size() > 0 || peer_ != nullptr;
252252
}
253253

254+
std::string ExtIface::get_iface_name() const {
255+
return iface_;
256+
}
257+
254258
} // namespace polycubed
255259
} // namespace polycube

src/polycubed/src/extiface.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ class ExtIface : public PeerIface {
4848
void set_next_index(uint16_t index);
4949
bool is_used() const;
5050

51+
std::string get_iface_name() const;
52+
5153
protected:
5254
static std::set<std::string> used_ifaces;
5355
int load_ingress();

src/polycubed/src/transparent_cube.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,11 @@ nlohmann::json TransparentCube::to_json() const {
151151

152152
std::string parent;
153153
if (parent_) {
154-
auto port_parent = dynamic_cast<Port *>(parent_);
155-
parent = port_parent->get_path();
154+
if (auto port_parent = dynamic_cast<Port *>(parent_)) {
155+
parent = port_parent->get_path();
156+
} else if (auto iface_parent = dynamic_cast<ExtIface *>(parent_)) {
157+
parent = iface_parent->get_iface_name();
158+
}
156159
}
157160

158161
j["parent"] = parent;

0 commit comments

Comments
 (0)