summaryrefslogtreecommitdiffstats
path: root/sys/netinet/raw_ip.c
diff options
context:
space:
mode:
authorandre <andre@FreeBSD.org>2005-08-22 16:13:08 +0000
committerandre <andre@FreeBSD.org>2005-08-22 16:13:08 +0000
commit573a9535a81268ee8fa937d020dad86235127d2c (patch)
treee4fae08b9c2716f53ec0fdfe0bc72046c99f26b9 /sys/netinet/raw_ip.c
parentef76245e903c6da9b4359edf312f385c9d1ab002 (diff)
downloadFreeBSD-src-573a9535a81268ee8fa937d020dad86235127d2c.zip
FreeBSD-src-573a9535a81268ee8fa937d020dad86235127d2c.tar.gz
Add socketoption IP_MINTTL. May be used to set the minimum acceptable
TTL a packet must have when received on a socket. All packets with a lower TTL are silently dropped. Works on already connected/connecting and listening sockets for RAW/UDP/TCP. This option is only really useful when set to 255 preventing packets from outside the directly connected networks reaching local listeners on sockets. Allows userland implementation of 'The Generalized TTL Security Mechanism (GTSM)' according to RFC3682. Examples of such use include the Cisco IOS BGP implementation command "neighbor ttl-security". MFC after: 2 weeks Sponsored by: TCP/IP Optimization Fundraise 2005
Diffstat (limited to 'sys/netinet/raw_ip.c')
-rw-r--r--sys/netinet/raw_ip.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/sys/netinet/raw_ip.c b/sys/netinet/raw_ip.c
index 3d2c6d2..8a128eb 100644
--- a/sys/netinet/raw_ip.c
+++ b/sys/netinet/raw_ip.c
@@ -157,6 +157,9 @@ raw_append(struct inpcb *last, struct ip *ip, struct mbuf *n)
if (!policyfail && mac_check_inpcb_deliver(last, n) != 0)
policyfail = 1;
#endif
+ /* Check the minimum TTL for socket. */
+ if (last->inp_ip_minttl && last->inp_ip_minttl > ip->ip_ttl)
+ policyfail = 1;
if (!policyfail) {
struct mbuf *opts = NULL;
struct socket *so;
OpenPOWER on IntegriCloud