]> git.ipfire.org Git - thirdparty/lldpd.git/commitdiff
marshal: don't marshal the list of chassis
authorVincent Bernat <bernat@luffy.cx>
Fri, 31 Aug 2012 05:52:43 +0000 (07:52 +0200)
committerVincent Bernat <bernat@luffy.cx>
Fri, 31 Aug 2012 05:52:43 +0000 (07:52 +0200)
We never need a list of chassis, just one chassis. Therefore, some
code is simplified by not transmitting the list.

src/daemon/event.c
src/lib/atom-private.c
src/lldpd-structs.h

index ca66a2ed454241540a3daca2cac441e0f0ec4f32..6bfeb10ccdcde8d0876ef5147654588524a26ce5 100644 (file)
@@ -247,24 +247,16 @@ levent_ctl_notify(char *ifname, int state, struct lldpd_port *neighbor)
 
                if (output == NULL) {
                        /* Ugly hack: we don't want to transmit a list of
-                        * chassis or a list of ports. We patch the chassis and
-                        * the port to avoid this. */
-                       TAILQ_ENTRY(lldpd_chassis) backup_c_entries;
+                        * ports. We patch the port to avoid this. */
                        TAILQ_ENTRY(lldpd_port) backup_p_entries;
                        memcpy(&backup_p_entries, &neighbor->p_entries,
                            sizeof(backup_p_entries));
-                       memcpy(&backup_c_entries, &neighbor->p_chassis->c_entries,
-                           sizeof(backup_c_entries));
                        memset(&neighbor->p_entries, 0,
                            sizeof(backup_p_entries));
-                       memset(&neighbor->p_chassis->c_entries, 0,
-                           sizeof(backup_c_entries));
                        output_len = marshal_serialize(lldpd_neighbor_change,
                            &neigh, &output);
                        memcpy(&neighbor->p_entries, &backup_p_entries,
                            sizeof(backup_p_entries));
-                       memcpy(&neighbor->p_chassis->c_entries, &backup_c_entries,
-                           sizeof(backup_c_entries));
 
                        if (output_len <= 0) {
                                LLOG_WARNX("unable to serialize changed neighbor");
index 73e7e7e140f18074bcd543e1e57c46610b399c61..27c31e9e4097d39c7c43a79fc3e0bae037bb2bc3 100644 (file)
@@ -433,19 +433,12 @@ static void
 add_chassis(struct chassis_list *chassis_list,
        struct lldpd_chassis *chassis)
 {
-       struct lldpd_chassis *one_chassis, *next_chassis;
-       /* This is an odd function because we want to add the chassis and the
-        * chained chassis which may not be referenced elsewhere. Serialization
-        * will bring us useless chassis in the mix. */
-       while (chassis) {
-               TAILQ_FOREACH(one_chassis, chassis_list, c_entries) {
-                       if (one_chassis == chassis) return;
-               }
-               next_chassis = TAILQ_NEXT(chassis, c_entries);
-               TAILQ_INSERT_TAIL(chassis_list,
-                   chassis, c_entries);
-               chassis = next_chassis;
+       struct lldpd_chassis *one_chassis;
+       TAILQ_FOREACH(one_chassis, chassis_list, c_entries) {
+               if (one_chassis == chassis) return;
        }
+       TAILQ_INSERT_TAIL(chassis_list,
+           chassis, c_entries);
 }
 
 static void
index d04d3c7b47e4219bfce26d5f32727ea4f2fbc11a..08d7d95a69efae78d02c75933e7b76b08664a220 100644 (file)
@@ -193,7 +193,8 @@ struct lldpd_chassis {
 /* WARNING: any change to this structure should also be reflected into
    `lldpd_copy_chassis()` which is not using marshaling. */
 MARSHAL_BEGIN(lldpd_chassis)
-MARSHAL_TQE(lldpd_chassis, c_entries)
+MARSHAL_IGNORE(lldpd_chassis, c_entries.tqe_next)
+MARSHAL_IGNORE(lldpd_chassis, c_entries.tqe_prev)
 MARSHAL_FSTR(lldpd_chassis, c_id, c_id_len)
 MARSHAL_STR(lldpd_chassis, c_name)
 MARSHAL_STR(lldpd_chassis, c_descr)