From: Yu Watanabe Date: Wed, 18 Jun 2025 01:24:23 +0000 (+0900) Subject: sd-lldp: replace ETHERTYPE_LLDP with ETH_P_LLDP X-Git-Tag: v258-rc1~287^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=92b64168f696a9a8794ba5977727dff2974b2879;p=thirdparty%2Fsystemd.git sd-lldp: replace ETHERTYPE_LLDP with ETH_P_LLDP ETH_P_LLDP is defined in linux/if_ether.h. --- diff --git a/src/basic/missing_network.h b/src/basic/missing_network.h index c5600d9fc67..1ece7101fd4 100644 --- a/src/basic/missing_network.h +++ b/src/basic/missing_network.h @@ -22,11 +22,6 @@ #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 diff --git a/src/libsystemd-network/lldp-neighbor.c b/src/libsystemd-network/lldp-neighbor.c index e35df5e145c..727e8feb331 100644 --- a/src/libsystemd-network/lldp-neighbor.c +++ b/src/libsystemd-network/lldp-neighbor.c @@ -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."); diff --git a/src/libsystemd-network/lldp-network.c b/src/libsystemd-network/lldp-network.c index 38e5ddb691d..53dd50c6068 100644 --- a/src/libsystemd-network/lldp-network.c +++ b/src/libsystemd-network/lldp-network.c @@ -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; diff --git a/src/libsystemd-network/sd-lldp-tx.c b/src/libsystemd-network/sd-lldp-tx.c index 9b86558ebaa..b836081d93c 100644 --- a/src/libsystemd-network/sd-lldp-tx.c +++ b/src/libsystemd-network/sd-lldp-tx.c @@ -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, };