]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[neighbour] Always use network device's own link-layer address
authorMichael Brown <mcb30@ipxe.org>
Mon, 5 Jan 2026 14:22:16 +0000 (14:22 +0000)
committerMichael Brown <mcb30@ipxe.org>
Mon, 5 Jan 2026 14:22:16 +0000 (14:22 +0000)
The API for neighbour_tx() allows for an explicit source link-layer
address, but this will be ignored if the packet is deferred for
transmission after completion of neighbour discovery.  The network
device's own link-layer address will always be used when sending
neighbour discovery packets, and when sending any deferred packets
after discovery completes.

All callers pass in the network device's own link-layer address as the
source address anyway, and so this explicit source link-layer address
is never used for any meaningful purpose.

Simplify the neighbour_tx() API by removing the ability to pass in an
explicit source link-layer address.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/include/ipxe/arp.h
src/include/ipxe/ndp.h
src/include/ipxe/neighbour.h
src/net/ipv4.c
src/net/ipv6.c
src/net/neighbour.c

index 5822fa095f34580aae3d92ae774286fe2be966df..674423c543bbbc3c78b8f96ef1b31e49b4c05229 100644 (file)
@@ -45,16 +45,14 @@ extern struct neighbour_discovery arp_discovery;
  * @v net_protocol     Network-layer protocol
  * @v net_dest         Destination network-layer address
  * @v net_source       Source network-layer address
- * @v ll_source                Source link-layer address
  * @ret rc             Return status code
  */
 static inline int arp_tx ( struct io_buffer *iobuf, struct net_device *netdev,
                           struct net_protocol *net_protocol,
-                          const void *net_dest, const void *net_source,
-                          const void *ll_source ) {
+                          const void *net_dest, const void *net_source ) {
 
        return neighbour_tx ( iobuf, netdev, net_protocol, net_dest,
-                             &arp_discovery, net_source, ll_source );
+                             &arp_discovery, net_source );
 }
 
 extern int arp_tx_request ( struct net_device *netdev,
index 1815236f5a2ed4ef055b85de54cf905ec405b27c..d06672ec1565a1ee60059d24b8c39fb11699d85c 100644 (file)
@@ -189,15 +189,13 @@ extern struct neighbour_discovery ndp_discovery;
  * @v netdev           Network device
  * @v net_dest         Destination network-layer address
  * @v net_source       Source network-layer address
- * @v ll_source                Source link-layer address
  * @ret rc             Return status code
  */
 static inline int ndp_tx ( struct io_buffer *iobuf, struct net_device *netdev,
-                          const void *net_dest, const void *net_source,
-                          const void *ll_source ) {
+                          const void *net_dest, const void *net_source ) {
 
        return neighbour_tx ( iobuf, netdev, &ipv6_protocol, net_dest,
-                             &ndp_discovery, net_source, ll_source );
+                             &ndp_discovery, net_source );
 }
 
 /** NDP settings block name */
index 1c1d1b6ca24471d48c794258b8dacfdf5472dda0..1ca0ee33355a759c64219516bb27504db6430f60 100644 (file)
@@ -77,7 +77,7 @@ extern int neighbour_tx ( struct io_buffer *iobuf, struct net_device *netdev,
                          struct net_protocol *net_protocol,
                          const void *net_dest,
                          struct neighbour_discovery *discovery,
-                         const void *net_source, const void *ll_source );
+                         const void *net_source );
 extern int neighbour_update ( struct net_device *netdev,
                              struct net_protocol *net_protocol,
                              const void *net_dest, const void *ll_dest );
index 03517840b6d195cc5ddee3cc9759beb2f451187e..21abfccec068744a415d6cfdb3e8c33f347f70c4 100644 (file)
@@ -563,7 +563,7 @@ static int ipv4_tx ( struct io_buffer *iobuf,
                }
        } else {
                if ( ( rc = arp_tx ( iobuf, netdev, &ipv4_protocol, &next_hop,
-                                    &iphdr->src, netdev->ll_addr ) ) != 0 ) {
+                                    &iphdr->src ) ) != 0 ) {
                        DBGC ( sin_dest->sin_addr, "IPv4 could not transmit "
                               "packet via %s: %s\n",
                               netdev->name, strerror ( rc ) );
index 8ee0804d3c22a0b68292f42cd97f566aef25eed5..b12d6577ec0ef3d427b9b4e5a327f7106cb8c1ce 100644 (file)
@@ -617,8 +617,8 @@ static int ipv6_tx ( struct io_buffer *iobuf,
                        return rc;
                }
        } else {
-               if ( ( rc = ndp_tx ( iobuf, netdev, next_hop, &iphdr->src,
-                                    netdev->ll_addr ) ) != 0 ) {
+               if ( ( rc = ndp_tx ( iobuf, netdev, next_hop,
+                                    &iphdr->src ) ) != 0 ) {
                        DBGC ( ipv6col ( &iphdr->dest ), "IPv6 could not "
                               "transmit packet via %s: %s\n",
                               netdev->name, strerror ( rc ) );
index 13a8bc3ba050537e389f4eecea9705eb5f8241ba..253cdc0e6751ace3ee76ac491693cf8054faeed3 100644 (file)
@@ -293,13 +293,12 @@ static void neighbour_expired ( struct retry_timer *timer, int fail ) {
  * @v net_protocol     Network-layer protocol
  * @v net_dest         Destination network-layer address
  * @v net_source       Source network-layer address
- * @v ll_source                Source link-layer address
  * @ret rc             Return status code
  */
 int neighbour_tx ( struct io_buffer *iobuf, struct net_device *netdev,
                   struct net_protocol *net_protocol, const void *net_dest,
                   struct neighbour_discovery *discovery,
-                  const void *net_source, const void *ll_source ) {
+                  const void *net_source ) {
        struct neighbour *neighbour;
 
        /* Find or create neighbour cache entry */
@@ -316,7 +315,7 @@ int neighbour_tx ( struct io_buffer *iobuf, struct net_device *netdev,
         */
        if ( neighbour_has_ll_dest ( neighbour ) ) {
                return net_tx ( iobuf, netdev, net_protocol, neighbour->ll_dest,
-                               ll_source );
+                               netdev->ll_addr );
        } else {
                DBGC2 ( neighbour, "NEIGHBOUR %s %s %s deferring packet\n",
                        netdev->name, net_protocol->name,