aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv6/ipv6_sockglue.c
diff options
context:
space:
mode:
authorStephen Hemminger <shemminger@vyatta.com>2010-04-22 18:24:53 -0400
committerDavid S. Miller <davem@davemloft.net>2010-04-22 18:24:53 -0400
commite802af9cabb011f09b9c19a82faef3dd315f27eb (patch)
tree9a8ef1163b9b40fef8860b08ea4dcb4ff3916098 /net/ipv6/ipv6_sockglue.c
parent9ccb8975940c4ee51161152e37058e3d9e06c62f (diff)
IPv6: Generic TTL Security Mechanism (final version)
This patch adds IPv6 support for RFC5082 Generalized TTL Security Mechanism. Not to users of mapped address; the IPV6 and IPV4 socket options are seperate. The server does have to deal with both IPv4 and IPv6 socket options and the client has to handle the different for each family. On client: int ttl = 255; getaddrinfo(argv[1], argv[2], &hint, &result); for (rp = result; rp != NULL; rp = rp->ai_next) { s = socket(rp->ai_family, rp->ai_socktype, rp->ai_protocol); if (s < 0) continue; if (rp->ai_family == AF_INET) { setsockopt(s, IPPROTO_IP, IP_TTL, &ttl, sizeof(ttl)); } else if (rp->ai_family == AF_INET6) { setsockopt(s, IPPROTO_IPV6, IPV6_UNICAST_HOPS, &ttl, sizeof(ttl))) } if (connect(s, rp->ai_addr, rp->ai_addrlen) == 0) { ... On server: int minttl = 255 - maxhops; getaddrinfo(NULL, port, &hints, &result); for (rp = result; rp != NULL; rp = rp->ai_next) { s = socket(rp->ai_family, rp->ai_socktype, rp->ai_protocol); if (s < 0) continue; if (rp->ai_family == AF_INET6) setsockopt(s, IPPROTO_IPV6, IPV6_MINHOPCOUNT, &minttl, sizeof(minttl)); setsockopt(s, IPPROTO_IP, IP_MINTTL, &minttl, sizeof(minttl)); if (bind(s, rp->ai_addr, rp->ai_addrlen) == 0) break ... Signed-off-by: Stephen Hemminger <shemminger@vyatta.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv6/ipv6_sockglue.c')
-rw-r--r--net/ipv6/ipv6_sockglue.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
index 1160400e9dbd..92295ad3487a 100644
--- a/net/ipv6/ipv6_sockglue.c
+++ b/net/ipv6/ipv6_sockglue.c
@@ -767,6 +767,14 @@ pref_skip_coa:
767 767
768 break; 768 break;
769 } 769 }
770 case IPV6_MINHOPCOUNT:
771 if (optlen < sizeof(int))
772 goto e_inval;
773 if (val < 0 || val > 255)
774 goto e_inval;
775 np->min_hopcount = val;
776 retv = 0;
777 break;
770 } 778 }
771 779
772 release_sock(sk); 780 release_sock(sk);
@@ -1116,6 +1124,10 @@ static int do_ipv6_getsockopt(struct sock *sk, int level, int optname,
1116 val |= IPV6_PREFER_SRC_HOME; 1124 val |= IPV6_PREFER_SRC_HOME;
1117 break; 1125 break;
1118 1126
1127 case IPV6_MINHOPCOUNT:
1128 val = np->min_hopcount;
1129 break;
1130
1119 default: 1131 default:
1120 return -ENOPROTOOPT; 1132 return -ENOPROTOOPT;
1121 } 1133 }