Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 26 Jun 2002 13:48:38 -0400
From:      Anthony Volodkin <anthonyv@brainlink.com>
To:        freebsd-net@freebsd.org
Subject:   Forwarding UDP packets
Message-ID:  <3D19FE76.1030404@brainlink.com>

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

Recently I've been faced with an odd problem.  I setup a pptp link to my
network from my friend's XP machine.  While the link functions fine
(both ends can ping each other, etc), there is one problem with it. I
cannot get any broadcast packets through the link.  I receive them on
the tun0 interface, but no matter what I try i can't get them out of the
fxp0 interface.  I cannot get them to go the other way either.  I know
this is against standards, as they suggest routers should not forward
broadcast packets, but I would still like to have this ability.

Did anyone ever write a patch of some sort or maybe found a tool that
does this type of thing?
(many people suggested natd, and after playing with that i was able to
redirect some bcast packets from tun0 to 1 host on my lan.  I was not
able to do that in the other direction, however.)

I've found an old post on the hackers list by Jonathan Chen that
included a patch to enable this kind of functionality. I applied it to
my 4.6-RELEASE kernel and it didn't do anything but add a sysctl
variable.  Any help would be greatly appreciated.

Here is that post:

---------------------------------------------------

On FreeBSD -CURRENT and -STABLE, packets to broadcast addresses are not
forwarded.  For instance, if I have a FreeBSD router with interfaces
192.168.1.1 and 192.168.2.1, and I send packets from 192.168.1.2 to
192.168.2.255, the packets are dropped to the floor.  IMO, this is wrong...
but I haven't consulted all the RFC's so I'm not sure if some standard out
there calls for it.  In any case, the following patch creates a sysctl knob
to turn on or off this feature (since it can be considered a security risk
by some).  I just want to ask around in case I turned out to be doing
something incredibly evil.  Comments?

-Jon

Index: in.h
===================================================================
RCS file: /export/ncvs/src/sys/netinet/in.h,v
retrieving revision 1.55
diff -u -r1.55 in.h
--- in.h 2001/06/15 00:37:27 1.55
+++ in.h 2001/08/09 15:12:19
@@ -452,7 +452,8 @@
  #define IPCTL_FASTFORWARDING 14 /* use fast IP forwarding code */
  #define IPCTL_KEEPFAITH  15 /* FAITH IPv4->IPv6 translater ctl */
  #define IPCTL_GIF_TTL  16 /* default TTL for gif encap packet */
-#define IPCTL_MAXID  17
+#define IPCTL_FORWARD_BROADCAST 18 /* forward broadcast packets */
+#define IPCTL_MAXID  18

  #define IPCTL_NAMES { \
   { 0, 0 }, \
Index: ip_input.c
===================================================================
RCS file: /export/ncvs/src/sys/netinet/ip_input.c,v
retrieving revision 1.174
diff -u -r1.174 ip_input.c
--- ip_input.c 2001/06/23 17:17:58 1.174
+++ ip_input.c 2001/08/09 15:33:59
@@ -103,6 +103,10 @@
  SYSCTL_INT(_net_inet_ip, IPCTL_FORWARDING, forwarding, CTLFLAG_RW,
      &ipforwarding, 0, "Enable IP forwarding between interfaces");

+int ipforward_broadcast = 0;
+SYSCTL_INT(_net_inet_ip, IPCTL_FORWARD_BROADCAST, forward_broadcast,
CTLFLAG_RW,
+    &ipforward_broadcast, 0, "Enable broadcast packets when forwarding
IP packets");
+
  static int ipsendredirects = 1; /* XXX */
  SYSCTL_INT(_net_inet_ip, IPCTL_SENDREDIRECTS, redirect, CTLFLAG_RW,
      &ipsendredirects, 0, "Enable sending IP redirects");
@@ -1684,7 +1688,8 @@
   }

   error = ip_output(m, (struct mbuf *)0, &ipforward_rt,
-     IP_FORWARDING, 0);
+     IP_FORWARDING|
+     (ipforward_broadcast?IP_ALLOWBROADCAST:0), 0);
   if (error)
    ipstat.ips_cantforward++;
   else {


--
Anthony Volodkin


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




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