Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 290057
b: refs/heads/master
c: c4062df
h: refs/heads/master
i:
  290055: b5bffee
v: v3
  • Loading branch information
Erich E. Hoover authored and David S. Miller committed Feb 8, 2012
1 parent 1cd88d8 commit a116591
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 2 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 76e21053b5bf33a07c76f99d27a74238310e3c71
refs/heads/master: c4062dfc425e94290ac427a98d6b4721dd2bc91f
1 change: 1 addition & 0 deletions trunk/include/linux/in6.h
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ struct in6_flowlabel_req {
#define IPV6_ORIGDSTADDR 74
#define IPV6_RECVORIGDSTADDR IPV6_ORIGDSTADDR
#define IPV6_TRANSPARENT 75
#define IPV6_UNICAST_IF 76

/*
* Multicast Routing:
Expand Down
1 change: 1 addition & 0 deletions trunk/include/linux/ipv6.h
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@ struct ipv6_pinfo {
__unused_2:6;
__s16 mcast_hops:9;
#endif
int ucast_oif;
int mcast_oif;

/* pktoption flags */
Expand Down
4 changes: 4 additions & 0 deletions trunk/net/ipv6/icmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,8 @@ void icmpv6_send(struct sk_buff *skb, u8 type, u8 code, __u32 info)

if (!fl6.flowi6_oif && ipv6_addr_is_multicast(&fl6.daddr))
fl6.flowi6_oif = np->mcast_oif;
else if (!fl6.flowi6_oif)
fl6.flowi6_oif = np->ucast_oif;

dst = icmpv6_route_lookup(net, skb, sk, &fl6);
if (IS_ERR(dst))
Expand Down Expand Up @@ -553,6 +555,8 @@ static void icmpv6_echo_reply(struct sk_buff *skb)

if (!fl6.flowi6_oif && ipv6_addr_is_multicast(&fl6.daddr))
fl6.flowi6_oif = np->mcast_oif;
else if (!fl6.flowi6_oif)
fl6.flowi6_oif = np->ucast_oif;

err = ip6_dst_lookup(sk, &dst, &fl6);
if (err)
Expand Down
34 changes: 34 additions & 0 deletions trunk/net/ipv6/ipv6_sockglue.c
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,36 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname,
retv = 0;
break;

case IPV6_UNICAST_IF:
{
struct net_device *dev = NULL;
int ifindex;

if (optlen != sizeof(int))
goto e_inval;

ifindex = (__force int)ntohl((__force __be32)val);
if (ifindex == 0) {
np->ucast_oif = 0;
retv = 0;
break;
}

dev = dev_get_by_index(net, ifindex);
retv = -EADDRNOTAVAIL;
if (!dev)
break;
dev_put(dev);

retv = -EINVAL;
if (sk->sk_bound_dev_if)
break;

np->ucast_oif = ifindex;
retv = 0;
break;
}

case IPV6_MULTICAST_IF:
if (sk->sk_type == SOCK_STREAM)
break;
Expand Down Expand Up @@ -1160,6 +1190,10 @@ static int do_ipv6_getsockopt(struct sock *sk, int level, int optname,
val = np->mcast_oif;
break;

case IPV6_UNICAST_IF:
val = (__force int)htonl((__u32) np->ucast_oif);
break;

case IPV6_MTU_DISCOVER:
val = np->pmtudisc;
break;
Expand Down
2 changes: 2 additions & 0 deletions trunk/net/ipv6/raw.c
Original file line number Diff line number Diff line change
Expand Up @@ -856,6 +856,8 @@ static int rawv6_sendmsg(struct kiocb *iocb, struct sock *sk,

if (!fl6.flowi6_oif && ipv6_addr_is_multicast(&fl6.daddr))
fl6.flowi6_oif = np->mcast_oif;
else if (!fl6.flowi6_oif)
fl6.flowi6_oif = np->ucast_oif;
security_sk_classify_flow(sk, flowi6_to_flowi(&fl6));

dst = ip6_dst_lookup_flow(sk, &fl6, final_p, true);
Expand Down
3 changes: 2 additions & 1 deletion trunk/net/ipv6/udp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1130,7 +1130,8 @@ int udpv6_sendmsg(struct kiocb *iocb, struct sock *sk,
if (!fl6.flowi6_oif && ipv6_addr_is_multicast(&fl6.daddr)) {
fl6.flowi6_oif = np->mcast_oif;
connected = 0;
}
} else if (!fl6.flowi6_oif)
fl6.flowi6_oif = np->ucast_oif;

security_sk_classify_flow(sk, flowi6_to_flowi(&fl6));

Expand Down

0 comments on commit a116591

Please sign in to comment.