8000 How to extract chassis info from neighbor · Issue #1779 · libevent/libevent · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
How to extract chassis info from neighbor #1779
Closed
@Ekmansoft

Description

@Ekmansoft

I must say it is not completely clear to me which atoms can be used on which interfaces in the lldpd API.

Specifically I am iterating through the neighbors to find my closest neighbor (a PSE POE switch or a POE injector), and want to know the id and type of this neighbor.

I want to extract who is powering my POE device, and am using the following code (with not shown null checks).

=========================

lldpctl_atom_t *iface_list = lldpctl_get_interfaces(class->connection);
lldpctl_atom_iter_t *iter = lldpctl_atom_iter(iface_list);
while (iter) {
lldpctl_atom_t *iface = lldpctl_atom_iter_value(iface_list, iter);

    lldpctl_atom_t *port = lldpctl_get_port(iface);
      lldpctl_atom_t *neighbors = lldpctl_atom_get(port, lldpctl_k_port_neighbors);

        lldpctl_atom_iter_t *neighbor_iter = lldpctl_atom_iter(neighbors);
        while (neighbor_iter) {
          lldpctl_atom_t *neighbor = lldpctl_atom_iter_value(neighbors, neighbor_iter);

          lldpctl_atom_t *chassis = lldpctl_atom_get(neighbor, lldpctl_k_port_chassis);
          if (chassis != NULL) {
            const char* chassis_name = lldpctl_atom_get_str(chassis, lldpctl_k_chassis_name); // <= Crashes here 

==============================

It works well on some devices, but on one device it has crashed with the following code dump:.

(There may be an inconsistency, as I am using

lldpctl_atom_get(neighbor, lldpctl_k_port_chassis);

to get the chassis info from the neighbor, but I have not seen any way to extract a port atom from a neighbor, and it works on some devices.)

==================

#0 0x0000007f89f79b50 in lldpctl_atom_get (atom=0x557acbb720, key=lldpctl_k_port_chassis) at /usr/src/debug/lldpd/1.0.17/src/lib/atom.c:62
#1 0x0000005560414778 in lldp_pse_extract_info (net_node=net_node@entry=0x557acbb720, neighbor_info=neighbor_info@entry=0x7fc4bfcde0) at lldp.c:56

===================

What could be the cause for this problem?

I am using the following chain of atom functions / atoms
get_interfaces() -> (iface_list) -> atom_iter(iface_list) / atom_iter_value(iface_list) -> (iface) -> lldpctl_get_port(iface) -> (port) -> atom_get(port,k_port_neighbors) -> (neighbors_list) atom_iter(neighbors_list) / atom_iter_value(neighbors_list) -> (neighbor) -> atom_get(neighbor, k_port_chassis) -> crash!

And it fails on this line

https://github.com/lldpd/lldpd/blob/master/src/lib/atom.c#L62

which contains:

RESET_ERROR(atom->conn);

Why is this happening?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0