Skip to content

Commit d55111d

Browse files
polycubed: show parent when attached to a netdev
A transparent cube can be attached to a standard cube's port or to a netdev, the conversion to json was failing to show it when the cube was attached to a netdev. Fixes: 8884259 ("use json as a configuration mechanishm for cubes and ports") Reported-by: Matteo Bertrone <m.bertrone@gmail.com> Signed-off-by: Mauricio Vasquez B <mauriciovasquezbernal@gmail.com>
1 parent 09d1bd5 commit d55111d

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)