FreeBSD Bugzilla – Attachment 244151 Details for
Bug 262828
[carp] CARP arp replays with wrong src mac
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
patch_broken
62f1195e17.patch (text/plain), 3.36 KB, created by
Ivan Rozhuk
on 2023-08-16 15:43:20 UTC
(
hide
)
Description:
patch_broken
Filename:
MIME Type:
Creator:
Ivan Rozhuk
Created:
2023-08-16 15:43:20 UTC
Size:
3.36 KB
patch
obsolete
>From 62f1195e17790ff4faa1abaaad086d4caa4ee852 Mon Sep 17 00:00:00 2001 >From: Rozhuk Ivan <rozhuk.im@gmail.com> >Date: Sat, 26 Mar 2022 12:28:14 +0300 >Subject: [PATCH] CARP: set CARP mac address as src in ethernet header of ARP > packet > >--- > sys/net/if_ethersubr.c | 16 +++++++++++++--- > sys/netinet/ip_carp.c | 12 ++++++++++++ > 2 files changed, 25 insertions(+), 3 deletions(-) > >diff --git a/sys/net/if_ethersubr.c b/sys/net/if_ethersubr.c >index 9a614fbe684..20c8a5da5f8 100644 >--- a/sys/net/if_ethersubr.c >+++ b/sys/net/if_ethersubr.c >@@ -97,6 +97,11 @@ CTASSERT(sizeof (struct ether_addr) == ETHER_ADDR_LEN); > > VNET_DEFINE(pfil_head_t, link_pfil_head); /* Packet filter hooks */ > >+#ifdef INET >+VNET_DECLARE(bool, use_carp_src_mac_in_arp); >+#define V_use_carp_src_mac VNET(use_carp_src_mac_in_arp) >+#endif >+ > /* netgraph node hooks for ng_ether(4) */ > void (*ng_ether_input_p)(struct ifnet *ifp, struct mbuf **mp); > void (*ng_ether_input_orphan_p)(struct ifnet *ifp, struct mbuf *m); >@@ -146,7 +151,7 @@ ether_requestencap(struct ifnet *ifp, struct if_encap_req *req) > struct ether_header *eh; > struct arphdr *ah; > uint16_t etype; >- const u_char *lladdr; >+ const u_char *lladdr, *llsaddr; > > if (req->rtype != IFENCAP_LL) > return (EOPNOTSUPP); >@@ -155,6 +160,7 @@ ether_requestencap(struct ifnet *ifp, struct if_encap_req *req) > return (ENOMEM); > > eh = (struct ether_header *)req->buf; >+ llsaddr = IF_LLADDR(ifp); > lladdr = req->lladdr; > req->lladdr_off = 0; > >@@ -180,7 +186,11 @@ ether_requestencap(struct ifnet *ifp, struct if_encap_req *req) > etype = htons(ETHERTYPE_ARP); > break; > } >- >+#ifdef INET >+ /* Set CARP MAC as src ethernet address. */ >+ if (ifp->if_carp && V_use_carp_src_mac) >+ llsaddr = ar_sha(ah); >+#endif > if (req->flags & IFENCAP_FLAG_BROADCAST) > lladdr = ifp->if_broadcastaddr; > break; >@@ -190,7 +200,7 @@ ether_requestencap(struct ifnet *ifp, struct if_encap_req *req) > > memcpy(&eh->ether_type, &etype, sizeof(eh->ether_type)); > memcpy(eh->ether_dhost, lladdr, ETHER_ADDR_LEN); >- memcpy(eh->ether_shost, IF_LLADDR(ifp), ETHER_ADDR_LEN); >+ memcpy(eh->ether_shost, llsaddr, ETHER_ADDR_LEN); > req->bufsize = sizeof(struct ether_header); > > return (0); >diff --git a/sys/netinet/ip_carp.c b/sys/netinet/ip_carp.c >index 2222c4eb0e5..89604e2c56c 100644 >--- a/sys/netinet/ip_carp.c >+++ b/sys/netinet/ip_carp.c >@@ -214,6 +214,12 @@ VNET_DEFINE_STATIC(int, carp_senderr_adj) = CARP_MAXSKEW; > VNET_DEFINE_STATIC(int, carp_ifdown_adj) = CARP_MAXSKEW; > #define V_carp_ifdown_adj VNET(carp_ifdown_adj) > >+/* Use CARP MAC as src addr in ethernet header of ARP packets.*/ >+#ifdef INET >+VNET_DEFINE(bool, use_carp_src_mac_in_arp) = false; >+#define V_use_carp_src_mac VNET(use_carp_src_mac_in_arp) >+#endif >+ > static int carp_allow_sysctl(SYSCTL_HANDLER_ARGS); > static int carp_dscp_sysctl(SYSCTL_HANDLER_ARGS); > static int carp_demote_adj_sysctl(SYSCTL_HANDLER_ARGS); >@@ -243,6 +249,12 @@ SYSCTL_INT(_net_inet_carp, OID_AUTO, ifdown_demotion_factor, > CTLFLAG_VNET | CTLFLAG_RW, > &VNET_NAME(carp_ifdown_adj), 0, > "Interface down demotion factor adjustment"); >+#ifdef INET >+SYSCTL_BOOL(_net_inet_carp, OID_AUTO, use_carp_src_mac_in_arp, >+ CTLFLAG_VNET | CTLFLAG_RW, >+ &VNET_NAME(use_carp_src_mac_in_arp), false, >+ "Use CARP MAC address as src address in ARP packet ethernet header."); >+#endif > > VNET_PCPUSTAT_DEFINE(struct carpstats, carpstats); > VNET_PCPUSTAT_SYSINIT(carpstats);
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 262828
:
232735
| 244151