Commit e183abe6 authored by Thomas Graf's avatar Thomas Graf

[NET] Convert sk_localroute into SOCK_LOCALROUTE flag and use RT_CONN_FLAGS where appropriate

Signed-off-by: default avatarThomas Graf <tgraf@suug.ch>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent edca4cb4
......@@ -44,7 +44,7 @@
/* RTO_CONN is not used (being alias for 0), but preserved not to break
* some modules referring to it. */
#define RT_CONN_FLAGS(sk) (RT_TOS(inet_sk(sk)->tos) | sk->sk_localroute)
#define RT_CONN_FLAGS(sk) (RT_TOS(inet_sk(sk)->tos) | sock_flag(sk, SOCK_LOCALROUTE))
struct inet_peer;
struct rtable
......
......@@ -147,7 +147,6 @@ struct sock_common {
* @sk_max_ack_backlog - listen backlog set in listen()
* @sk_priority - %SO_PRIORITY setting
* @sk_type - socket type (%SOCK_STREAM, etc)
* @sk_localroute - route locally only, %SO_DONTROUTE setting
* @sk_protocol - which protocol this socket belongs in this network family
* @sk_peercred - %SO_PEERCRED setting
* @sk_rcvlowat - %SO_RCVLOWAT setting
......@@ -226,7 +225,6 @@ struct sock {
unsigned short sk_max_ack_backlog;
__u32 sk_priority;
unsigned short sk_type;
unsigned char sk_localroute;
unsigned char sk_protocol;
struct ucred sk_peercred;
int sk_rcvlowat;
......@@ -386,6 +384,7 @@ enum sock_flags {
SOCK_DBG, /* %SO_DEBUG setting */
SOCK_RCVTSTAMP, /* %SO_TIMESTAMP setting */
SOCK_NO_LARGESEND, /* whether to sent large segments or not */
SOCK_LOCALROUTE, /* route locally only, %SO_DONTROUTE setting */
};
static inline void sock_set_flag(struct sock *sk, enum sock_flags flag)
......
......@@ -241,7 +241,10 @@ int sock_setsockopt(struct socket *sock, int level, int optname,
ret = -ENOPROTOOPT;
break;
case SO_DONTROUTE:
sk->sk_localroute = valbool;
if (valbool)
sock_set_flag(sk, SOCK_LOCALROUTE);
else
sock_reset_flag(sk, SOCK_LOCALROUTE);
break;
case SO_BROADCAST:
sock_valbool_flag(sk, SOCK_BROADCAST, valbool);
......@@ -474,7 +477,7 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
break;
case SO_DONTROUTE:
v.val = sk->sk_localroute;
v.val = sock_flag(sk, SOCK_LOCALROUTE);
break;
case SO_BROADCAST:
......
......@@ -457,7 +457,7 @@ static int raw_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
daddr = ipc.opt->faddr;
}
}
tos = RT_TOS(inet->tos) | sk->sk_localroute;
tos = RT_CONN_FLAGS(sk);
if (msg->msg_flags & MSG_DONTROUTE)
tos |= RTO_ONLINK;
......
......@@ -1866,7 +1866,7 @@ static int tcp_v4_reselect_saddr(struct sock *sk)
/* Query new route. */
err = ip_route_connect(&rt, daddr, 0,
RT_TOS(inet->tos) | sk->sk_localroute,
RT_CONN_FLAGS(sk),
sk->sk_bound_dev_if,
IPPROTO_TCP,
inet->sport, inet->dport, sk);
......
......@@ -574,7 +574,8 @@ int udp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
connected = 0;
}
tos = RT_TOS(inet->tos);
if (sk->sk_localroute || (msg->msg_flags & MSG_DONTROUTE) ||
if (sock_flag(sk, SOCK_LOCALROUTE) ||
(msg->msg_flags & MSG_DONTROUTE) ||
(ipc.opt && ipc.opt->is_strictroute)) {
tos |= RTO_ONLINK;
connected = 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment