#ifdef notyet
#define IPCTL_DEFMTU 4 /* default MTU */
#endif
-#define IPCTL_MAXID 5
+#define IPCTL_SOURCEROUTE 5 /* may perform source routes */
+#define IPCTL_MAXID 6
#define IPCTL_NAMES { \
{ 0, 0 }, \
{ "redirect", CTLTYPE_INT }, \
{ "ttl", CTLTYPE_INT }, \
{ "mtu", CTLTYPE_INT }, \
+ { "sourceroute", CTLTYPE_INT }, \
}
#include <sys/errno.h>
#include <sys/time.h>
#include <sys/kernel.h>
+#include <sys/syslog.h>
#include <net/if.h>
#include <net/route.h>
#endif
int ipforwarding = IPFORWARDING;
int ipsendredirects = IPSENDREDIRECTS;
+int ip_dosourceroute = 0; /* no source routing unless sysctl'd to enable */
int ip_defttl = IPDEFTTL;
#ifdef DIAGNOSTIC
int ipprintfs = 0;
save_rte(cp, ip->ip_src);
break;
}
+
+ if (!ip_dosourceroute) {
+#if 0
+ char buf[4*sizeof "123"];
+ strcpy(buf, inet_ntoa(ip->ip_dst));
+
+ log(LOG_WARNING,
+ "attempted source route from %s to %s\n",
+ inet_ntoa(ip->ip_src), buf);
+#endif
+ type = ICMP_UNREACH;
+ code = ICMP_UNREACH_SRCFAIL;
+ goto bad;
+ }
+
/*
* locate outgoing interface
*/
code = ICMP_REDIRECT_HOST;
#ifdef DIAGNOSTIC
if (ipprintfs)
- printf("redirect (%d) to %lx\n", code, (u_int32_t)dest);
+ printf("redirect (%d) to %lx\n", code, (u_int32_t)dest);
#endif
}
}
case IPCTL_DEFMTU:
return (sysctl_int(oldp, oldlenp, newp, newlen, &ip_mtu));
#endif
+ case IPCTL_SOURCEROUTE:
+ return (sysctl_int(oldp, oldlenp, newp, newlen, &ip_dosourceroute));
default:
return (EOPNOTSUPP);
}