Bug 12847

Summary: [PATCH] Fix for "Proxy ARP"
Product: Base System Reporter: KT Sin <ktsin>
Component: binAssignee: ru <ru>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: 3.2-STABLE   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
file.diff none

Description KT Sin 1999-07-28 02:50:00 UTC
See PR bin/12448.

Fix: A buffer containing sockaddrs (RTA_DST, RTA_GATEWAY, RTA_NETMASK) 
is passed to and from the kernel. Arp did not align the sockaddrs
when constructing the buffer but the kernel (rtsock.c) required the
starting address of each sockaddr in the buffer to be a multiple of 4.

Arp -s broke when the size of sockaddr_dl (RTA_GATEWAY) increased from
20 to 54 after some new elements were added. So RTA_NETMASK was copied
to and from the wrong offset by rtsock.c (offset 16+56) and arp.c
(offset 16+54).

ROUNDUP() macro is now used in arp.c when copying sockaddr structures to
and from the buffer.

The patch is included below. Please fetch from
http://www.daddylonglegs.com/arp.patch if you encounter problems with
spaces, tabs and newlines.

==========================================cut here============================================
#define SETFUNC(f)    { if (func) usage(); func = (f); }

+ #define ROUNDUP(a) \
+         ((a) > 0 ? (1 + (((a) - 1) | (sizeof(long) - 1))) : sizeof(long))
+
  int
  main(argc, argv)
        int argc;
***************


NEXTADDR(RTA_DST, sin_m);
        NEXTADDR(RTA_GATEWAY, sdl_m);
--- 610,616 ----
        }
  #define NEXTADDR(w, s) \
        if (rtm->rtm_addrs & (w)) { \
!               bcopy((char *)&s, cp, sizeof(s)); cp += ROUNDUP(sizeof(s));}

        NEXTADDR(RTA_DST, sin_m);
        NEXTADDR(RTA_GATEWAY, sdl_m);
============================================cut here========================================--ApYkN7NSFFu5mZzc5hYPFkDkvKSBwVjZywzHQydOxnzylztc
Content-Type: text/plain; name="file.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="file.diff"

*** usr.sbin/arp/arp.c.orig     Sun Jun  6 10:26:08 1999
--- usr.sbin/arp/arp.c  Mon Jul 26 18:05:12 1999
***************
*** 112,117 ****
--- 112,120 ----
How-To-Repeat: See PR bin/12448.
Comment 1 jooji 1999-09-10 20:11:59 UTC
Could someone please make sure the patch in this PR is committed before
3.3 is released?
Comment 2 Sheldon Hearn freebsd_committer freebsd_triage 1999-09-13 17:23:05 UTC
Responsible Changed
From-To: freebsd-bugs->ru

Ruslan Ermilov is taking care of this. 
Comment 3 ru freebsd_committer freebsd_triage 1999-09-14 01:00:02 UTC
State Changed
From-To: open->feedback

Fixed in -current (arp.c,v 1.18). 
Awaiting approval from Jordan to MFC. 
Comment 4 ru freebsd_committer freebsd_triage 1999-09-14 09:45:22 UTC
State Changed
From-To: feedback->closed

Fixed in -stable (arp.c,v 1.14.2.4).