Skip to content
Snippets Groups Projects
Commit 830967cb authored by Marina Maslova's avatar Marina Maslova Committed by Marina Maslova
Browse files

use bridge interface for arping if interface is in the bridge

In case of bridge kernel uses bridge MAC for regular packets.
Passing of interface source MAC instead of bridge might produce
conflicting ARP entry on other side, because same IP has bridge
MAC and at the same time interface MAC which might differ.
parent b707c6f1
No related branches found
No related tags found
1 merge request!41use bridge interface for arping if interface is in the bridge
Pipeline #202142 passed
...@@ -99,21 +99,29 @@ int arping_send_arp_request(struct neigh_entry *n, char dip[]) ...@@ -99,21 +99,29 @@ int arping_send_arp_request(struct neigh_entry *n, char dip[])
return -1; return -1;
} }
char *sifname = n->ifname;
char smac[20] = {0}; char smac[20] = {0};
char sip[46] = {0}; char sip[46] = {0};
char dmac[20] = {0}; char dmac[20] = {0};
hwaddr_ntoa(iface->macaddr, smac); char brifname[16] = {0};
/* Try to find bridge IP address in order to use as source IP */ struct local_interface *briface = NULL;
const char *brifname = DEFAULT_LAN_IFNAME;
struct local_interface *briface = hostmngr_ifname_to_interface(priv, brifname);
bool is_brip_find = false; bool is_brip_find = false;
int brifindex;
/* Try to find bridge IP address in order to use as source IP */
brifindex = if_isbridge_interface(n->ifname);
if (brifindex > 0 && if_indextoname(brifindex, brifname))
briface = hostmngr_ifname_to_interface(priv, brifname);
if (briface) { if (briface) {
for (int i = 0; i < briface->num_ipaddrs; i++) { for (int i = 0; i < briface->num_ipaddrs; i++) {
if (briface->ipaddrs[i].family != AF_INET) if (briface->ipaddrs[i].family != AF_INET)
continue; continue;
inet_ntop(AF_INET/*ipv4 only*/, &briface->ipaddrs[i].addr, sip, sizeof(sip)); inet_ntop(AF_INET/*ipv4 only*/, &briface->ipaddrs[i].addr, sip, sizeof(sip));
is_brip_find = true; is_brip_find = true;
hwaddr_ntoa(briface->macaddr, smac);
sifname = brifname;
break; break;
} }
} }
...@@ -121,12 +129,13 @@ int arping_send_arp_request(struct neigh_entry *n, char dip[]) ...@@ -121,12 +129,13 @@ int arping_send_arp_request(struct neigh_entry *n, char dip[])
dbg("Failed to find a valid IP address for brifname %s to use as source IP, " dbg("Failed to find a valid IP address for brifname %s to use as source IP, "
"will be using 0.0.0.0\n", brifname); "will be using 0.0.0.0\n", brifname);
snprintf(sip, sizeof(sip), "0.0.0.0"); snprintf(sip, sizeof(sip), "0.0.0.0");
hwaddr_ntoa(iface->macaddr, smac);
} }
hwaddr_ntoa(n->macaddr, dmac); hwaddr_ntoa(n->macaddr, dmac);
dbg("arping to {ifname: %s, smac: %s, sip: %s, dmac: %s, dip: %s}\n", dbg("arping to {ifname: %s, smac: %s, sip: %s, dmac: %s, dip: %s}\n",
n->ifname, smac, sip, dmac, dip); sifname, smac, sip, dmac, dip);
return send_arp_request(n->ifname, smac, sip, dmac, dip); return send_arp_request(sifname, smac, sip, dmac, dip);
} }
#else #else
/* Convert \x001122334455 --> "00:11:22:33:44:55" */ /* Convert \x001122334455 --> "00:11:22:33:44:55" */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment