Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 27 Jul 1999 18:43:36 -0700 (PDT)
From:      ktsin@acm.org
To:        freebsd-gnats-submit@freebsd.org
Subject:   bin/12847: [PATCH] Fix for "Proxy ARP"
Message-ID:  <19990728014336.3ED8514CA7@hub.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         12847
>Category:       bin
>Synopsis:       [PATCH] Fix for "Proxy ARP"
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Jul 27 18:50:00 PDT 1999
>Closed-Date:
>Last-Modified:
>Originator:     Key Teck Sin
>Release:        FreeBSD 3.2-STABLE
>Organization:
>Environment:
FreeBSD daffodil.singtel-yp.com 3.2-STABLE FreeBSD 3.2-STABLE #0: Sun Jul 18 15:45:00 SGT 1999     root@daffodil:/usr/src/sys/compile/DAFFODIL  i386
>Description:
See PR bin/12448.
>How-To-Repeat:
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============================================
*** 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 ----

  #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;
***************
*** 494,504 ****
                printf(" published (proxy only)");
        if (rtm->rtm_addrs & RTA_NETMASK) {
                sin = (struct sockaddr_inarp *)
!                       (sdl->sdl_len + (char *)sdl);
                if (sin->sin_addr.s_addr == 0xffffffff)
                        printf(" published");
                if (sin->sin_len != 8)
!                       printf("(wierd)");
        }
          switch(sdl->sdl_type) {
              case IFT_ETHER:
--- 497,507 ----
                printf(" published (proxy only)");
        if (rtm->rtm_addrs & RTA_NETMASK) {
                sin = (struct sockaddr_inarp *)
!                       (ROUNDUP(sdl->sdl_len) + (char *)sdl);
                if (sin->sin_addr.s_addr == 0xffffffff)
                        printf(" published");
                if (sin->sin_len != 8)
!                       printf("(weird)");
        }
          switch(sdl->sdl_type) {
              case IFT_ETHER:
***************
*** 607,613 ****
        }
  #define NEXTADDR(w, s) \
        if (rtm->rtm_addrs & (w)) { \
!               bcopy((char *)&s, cp, sizeof(s)); cp += sizeof(s);}

        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========================================

>Release-Note:
>Audit-Trail:
>Unformatted:


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19990728014336.3ED8514CA7>