aboutgitcodebugslistschat
path: root/tap.c
diff options
context:
space:
mode:
authorDavid Gibson <david@gibson.dropbear.id.au>2024-08-21 14:19:59 +1000
committerStefano Brivio <sbrivio@redhat.com>2024-08-21 11:59:54 +0200
commit905ecd2b0b8a6ab68b66017ec47e094253233e74 (patch)
tree17b470748c32e17d690620315f293efded491fe4 /tap.c
parent066e69986b96bf83dfa2ec09f6b03b6a7ad6bbd6 (diff)
downloadpasst-905ecd2b0b8a6ab68b66017ec47e094253233e74.tar
passt-905ecd2b0b8a6ab68b66017ec47e094253233e74.tar.gz
passt-905ecd2b0b8a6ab68b66017ec47e094253233e74.tar.bz2
passt-905ecd2b0b8a6ab68b66017ec47e094253233e74.tar.lz
passt-905ecd2b0b8a6ab68b66017ec47e094253233e74.tar.xz
passt-905ecd2b0b8a6ab68b66017ec47e094253233e74.tar.zst
passt-905ecd2b0b8a6ab68b66017ec47e094253233e74.zip
treewide: Rename MAC address fields for clarity
c->mac isn't a great name, because it doesn't say whose mac address it is and it's not necessarily obvious in all the contexts we use it. Since this is specifically the address that we (passt/pasta) use on the tap interface, rename it to "our_tap_mac". Rename the "mac_guest" field to "guest_mac" to be grammatically consistent. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Diffstat (limited to 'tap.c')
-rw-r--r--tap.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/tap.c b/tap.c
index 87be3a6..852d837 100644
--- a/tap.c
+++ b/tap.c
@@ -118,8 +118,8 @@ static void *tap_push_l2h(const struct ctx *c, void *buf, uint16_t proto)
struct ethhdr *eh = (struct ethhdr *)buf;
/* TODO: ARP table lookup */
- memcpy(eh->h_dest, c->mac_guest, ETH_ALEN);
- memcpy(eh->h_source, c->mac, ETH_ALEN);
+ memcpy(eh->h_dest, c->guest_mac, ETH_ALEN);
+ memcpy(eh->h_source, c->our_tap_mac, ETH_ALEN);
eh->h_proto = ntohs(proto);
return eh + 1;
}
@@ -946,9 +946,9 @@ void tap_add_packet(struct ctx *c, ssize_t l2len, char *p)
eh = (struct ethhdr *)p;
- if (memcmp(c->mac_guest, eh->h_source, ETH_ALEN)) {
- memcpy(c->mac_guest, eh->h_source, ETH_ALEN);
- proto_update_l2_buf(c->mac_guest, NULL);
+ if (memcmp(c->guest_mac, eh->h_source, ETH_ALEN)) {
+ memcpy(c->guest_mac, eh->h_source, ETH_ALEN);
+ proto_update_l2_buf(c->guest_mac, NULL);
}
switch (ntohs(eh->h_proto)) {
@@ -1337,6 +1337,6 @@ void tap_sock_init(struct ctx *c)
* sends us packets. Use the broadcast address so that our
* first packets will reach it.
*/
- memset(&c->mac_guest, 0xff, sizeof(c->mac_guest));
+ memset(&c->guest_mac, 0xff, sizeof(c->guest_mac));
}
}