]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sd-lldp: replace ETHERTYPE_LLDP with ETH_P_LLDP
authorYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 18 Jun 2025 01:24:23 +0000 (10:24 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 19 Jun 2025 10:08:45 +0000 (19:08 +0900)
ETH_P_LLDP is defined in linux/if_ether.h.

src/basic/missing_network.h
src/libsystemd-network/lldp-neighbor.c
src/libsystemd-network/lldp-network.c
src/libsystemd-network/sd-lldp-tx.c

index c5600d9fc67b3cd747b979c53e9463335549a118..1ece7101fd42437b8e0045ed86adff370012656b 100644 (file)
 #define LOOPBACK_IFINDEX 1
 #endif
 
-/* Not exposed yet. Similar values are defined in net/ethernet.h */
-#ifndef ETHERTYPE_LLDP
-#define ETHERTYPE_LLDP 0x88cc
-#endif
-
 /* Not exposed but defined in linux/netdevice.h */
 #ifndef MAX_PHYS_ITEM_ID_LEN
 #define MAX_PHYS_ITEM_ID_LEN 32
index e35df5e145cbd5877c5de6e1c87cc22d511848a3..727e8feb3319f847f906e2ecc114f82a16ae5c84 100644 (file)
@@ -10,7 +10,6 @@
 #include "lldp-neighbor.h"
 #include "lldp-rx-internal.h"
 #include "memory-util.h"
-#include "missing_network.h"
 #include "prioq.h"
 #include "siphash24.h"
 #include "unaligned.h"
@@ -181,7 +180,7 @@ int lldp_neighbor_parse(sd_lldp_neighbor *n) {
 
         memcpy(&h, LLDP_NEIGHBOR_RAW(n), sizeof(h));
 
-        if (h.ether_type != htobe16(ETHERTYPE_LLDP))
+        if (h.ether_type != htobe16(ETH_P_LLDP))
                 return log_lldp_rx_errno(n->lldp_rx, SYNTHETIC_ERRNO(EBADMSG),
                                          "Received packet with wrong type, ignoring.");
 
index 38e5ddb691dcaa6482e7e34d290ccea0a2a88e33..53dd50c6068874f8dbe523077153575882c7a92d 100644 (file)
@@ -4,7 +4,6 @@
 
 #include "fd-util.h"
 #include "lldp-network.h"
-#include "missing_network.h"
 #include "socket-util.h"
 
 int lldp_network_bind_raw_socket(int ifindex) {
@@ -18,7 +17,7 @@ int lldp_network_bind_raw_socket(int ifindex) {
                 BPF_JUMP(BPF_JMP + BPF_JEQ + BPF_K, 0x000e, 1, 0),                        /* A != 00:0e */
                 BPF_STMT(BPF_RET + BPF_K, 0),                                             /* drop packet */
                 BPF_STMT(BPF_LD + BPF_H + BPF_ABS, offsetof(struct ethhdr, h_proto)),     /* A <- protocol */
-                BPF_JUMP(BPF_JMP + BPF_JEQ + BPF_K, ETHERTYPE_LLDP, 1, 0),                /* A != ETHERTYPE_LLDP */
+                BPF_JUMP(BPF_JMP + BPF_JEQ + BPF_K, ETH_P_LLDP, 1, 0),                    /* A != ETH_P_LLDP */
                 BPF_STMT(BPF_RET + BPF_K, 0),                                             /* drop packet */
                 BPF_STMT(BPF_RET + BPF_K, UINT32_MAX),                                    /* accept packet */
         };
@@ -41,7 +40,7 @@ int lldp_network_bind_raw_socket(int ifindex) {
         assert(ifindex > 0);
 
         fd = socket(AF_PACKET, SOCK_RAW|SOCK_CLOEXEC|SOCK_NONBLOCK,
-                    htobe16(ETHERTYPE_LLDP));
+                    htobe16(ETH_P_LLDP));
         if (fd < 0)
                 return -errno;
 
index 9b86558ebaac18b3d1b03a2b222bb2d4d7d68fce..b836081d93c3f8a57bf9000162a0cc045cb67252 100644 (file)
@@ -391,7 +391,7 @@ static int lldp_tx_create_packet(sd_lldp_tx *lldp_tx, size_t *ret_packet_size, u
                 return -ENOMEM;
 
         header = (struct ether_header*) packet;
-        header->ether_type = htobe16(ETHERTYPE_LLDP);
+        header->ether_type = htobe16(ETH_P_LLDP);
         memcpy(header->ether_dhost, lldp_multicast_addr + lldp_tx->mode, ETH_ALEN);
         memcpy(header->ether_shost, &lldp_tx->hwaddr, ETH_ALEN);
 
@@ -502,7 +502,7 @@ static int lldp_tx_send_packet(sd_lldp_tx *lldp_tx, size_t packet_size, const ui
 
         sa = (union sockaddr_union) {
                 .ll.sll_family = AF_PACKET,
-                .ll.sll_protocol = htobe16(ETHERTYPE_LLDP),
+                .ll.sll_protocol = htobe16(ETH_P_LLDP),
                 .ll.sll_ifindex = lldp_tx->ifindex,
                 .ll.sll_halen = ETH_ALEN,
         };