diff options
author | Lennart Poettering <lennart@poettering.net> | 2016-02-21 14:11:34 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2016-02-21 20:40:58 +0100 |
commit | b553a6b13c68cb72addde48281abe3f3b46e16a4 (patch) | |
tree | d8f8548603e1bd3a2812257eae233fba546e2e24 /src/libsystemd-network/sd-lldp.c | |
parent | 33859a6bf5fd2b62a562a751a509708617e19776 (diff) |
sd-lldp: filter out LLDP messages coming from our own MAC address
Let's not get confused should we be connected to some bridge that mirrors back
our packets.
Diffstat (limited to 'src/libsystemd-network/sd-lldp.c')
-rw-r--r-- | src/libsystemd-network/sd-lldp.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/libsystemd-network/sd-lldp.c b/src/libsystemd-network/sd-lldp.c index 65cfa4e184..3af6133a4e 100644 --- a/src/libsystemd-network/sd-lldp.c +++ b/src/libsystemd-network/sd-lldp.c @@ -28,6 +28,7 @@ #include "lldp-neighbor.h" #include "lldp-network.h" #include "socket-util.h" +#include "ether-addr-util.h" #define LLDP_DEFAULT_NEIGHBORS_MAX 128U @@ -99,6 +100,11 @@ static int lldp_add_neighbor(sd_lldp *lldp, sd_lldp_neighbor *n) { if (n->ttl <= 0) return changed; + /* Filter out the filter address */ + if (!ether_addr_is_null(&lldp->filter_address) && + ether_addr_equal(&lldp->filter_address, &n->source_address)) + return changed; + /* Only add if the neighbor has a capability we are interested in. Note that we also store all neighbors with * no caps field set. */ if (n->has_capabilities && @@ -438,3 +444,18 @@ _public_ int sd_lldp_match_capabilities(sd_lldp *lldp, uint16_t mask) { return 0; } + +_public_ int sd_lldp_set_filter_address(sd_lldp *lldp, const struct ether_addr *addr) { + assert_return(lldp, -EINVAL); + + /* In order to deal nicely with bridges that send back our own packets, allow one address to be filtered, so + * that our own can be filtered out here. */ + + if (!addr) { + zero(lldp->filter_address); + return 0; + } + + lldp->filter_address = *addr; + return 0; +} |