aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4
diff options
context:
space:
mode:
authorOctavian Purdila <octavian.purdila@intel.com>2014-06-25 10:09:53 -0400
committerDavid S. Miller <davem@davemloft.net>2014-06-27 18:53:35 -0400
commit16bea70aa7302b6f3bf3502d5a0efb4ea2ce4712 (patch)
treec4ea18d24ad49b0ebb47211e810dd50e1b67f404 /net/ipv4
parent476eab8251641ea2ae4666ca8a1436ebc2b8e9c3 (diff)
tcp: add init_req method to tcp_request_sock_ops
Move the specific IPv4/IPv6 intializations to a new method in tcp_request_sock_ops in preparation for unifying tcp_v4_conn_request and tcp_v6_conn_request. Signed-off-by: Octavian Purdila <octavian.purdila@intel.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4')
-rw-r--r--net/ipv4/tcp_ipv4.c29
1 files changed, 17 insertions, 12 deletions
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index 145f6402c560..f86a86b30d20 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -1237,6 +1237,17 @@ static bool tcp_v4_inbound_md5_hash(struct sock *sk, const struct sk_buff *skb)
1237 1237
1238#endif 1238#endif
1239 1239
1240static void tcp_v4_init_req(struct request_sock *req, struct sock *sk,
1241 struct sk_buff *skb)
1242{
1243 struct inet_request_sock *ireq = inet_rsk(req);
1244
1245 ireq->ir_loc_addr = ip_hdr(skb)->daddr;
1246 ireq->ir_rmt_addr = ip_hdr(skb)->saddr;
1247 ireq->no_srccheck = inet_sk(sk)->transparent;
1248 ireq->opt = tcp_v4_save_options(skb);
1249}
1250
1240struct request_sock_ops tcp_request_sock_ops __read_mostly = { 1251struct request_sock_ops tcp_request_sock_ops __read_mostly = {
1241 .family = PF_INET, 1252 .family = PF_INET,
1242 .obj_size = sizeof(struct tcp_request_sock), 1253 .obj_size = sizeof(struct tcp_request_sock),
@@ -1247,26 +1258,26 @@ struct request_sock_ops tcp_request_sock_ops __read_mostly = {
1247 .syn_ack_timeout = tcp_syn_ack_timeout, 1258 .syn_ack_timeout = tcp_syn_ack_timeout,
1248}; 1259};
1249 1260
1250#ifdef CONFIG_TCP_MD5SIG
1251static const struct tcp_request_sock_ops tcp_request_sock_ipv4_ops = { 1261static const struct tcp_request_sock_ops tcp_request_sock_ipv4_ops = {
1262#ifdef CONFIG_TCP_MD5SIG
1252 .md5_lookup = tcp_v4_reqsk_md5_lookup, 1263 .md5_lookup = tcp_v4_reqsk_md5_lookup,
1253 .calc_md5_hash = tcp_v4_md5_hash_skb, 1264 .calc_md5_hash = tcp_v4_md5_hash_skb,
1254};
1255#endif 1265#endif
1266 .init_req = tcp_v4_init_req,
1267};
1256 1268
1257int tcp_v4_conn_request(struct sock *sk, struct sk_buff *skb) 1269int tcp_v4_conn_request(struct sock *sk, struct sk_buff *skb)
1258{ 1270{
1259 struct tcp_options_received tmp_opt; 1271 struct tcp_options_received tmp_opt;
1260 struct request_sock *req; 1272 struct request_sock *req;
1261 struct inet_request_sock *ireq;
1262 struct tcp_sock *tp = tcp_sk(sk); 1273 struct tcp_sock *tp = tcp_sk(sk);
1263 struct dst_entry *dst = NULL; 1274 struct dst_entry *dst = NULL;
1264 __be32 saddr = ip_hdr(skb)->saddr; 1275 __be32 saddr = ip_hdr(skb)->saddr;
1265 __be32 daddr = ip_hdr(skb)->daddr;
1266 __u32 isn = TCP_SKB_CB(skb)->when; 1276 __u32 isn = TCP_SKB_CB(skb)->when;
1267 bool want_cookie = false, fastopen; 1277 bool want_cookie = false, fastopen;
1268 struct flowi4 fl4; 1278 struct flowi4 fl4;
1269 struct tcp_fastopen_cookie foc = { .len = -1 }; 1279 struct tcp_fastopen_cookie foc = { .len = -1 };
1280 const struct tcp_request_sock_ops *af_ops;
1270 int err; 1281 int err;
1271 1282
1272 /* Never answer to SYNs send to broadcast or multicast */ 1283 /* Never answer to SYNs send to broadcast or multicast */
@@ -1298,9 +1309,7 @@ int tcp_v4_conn_request(struct sock *sk, struct sk_buff *skb)
1298 if (!req) 1309 if (!req)
1299 goto drop; 1310 goto drop;
1300 1311
1301#ifdef CONFIG_TCP_MD5SIG 1312 af_ops = tcp_rsk(req)->af_specific = &tcp_request_sock_ipv4_ops;
1302 tcp_rsk(req)->af_specific = &tcp_request_sock_ipv4_ops;
1303#endif
1304 1313
1305 tcp_clear_options(&tmp_opt); 1314 tcp_clear_options(&tmp_opt);
1306 tmp_opt.mss_clamp = TCP_MSS_DEFAULT; 1315 tmp_opt.mss_clamp = TCP_MSS_DEFAULT;
@@ -1313,11 +1322,7 @@ int tcp_v4_conn_request(struct sock *sk, struct sk_buff *skb)
1313 tmp_opt.tstamp_ok = tmp_opt.saw_tstamp; 1322 tmp_opt.tstamp_ok = tmp_opt.saw_tstamp;
1314 tcp_openreq_init(req, &tmp_opt, skb, sk); 1323 tcp_openreq_init(req, &tmp_opt, skb, sk);
1315 1324
1316 ireq = inet_rsk(req); 1325 af_ops->init_req(req, sk, skb);
1317 ireq->ir_loc_addr = daddr;
1318 ireq->ir_rmt_addr = saddr;
1319 ireq->no_srccheck = inet_sk(sk)->transparent;
1320 ireq->opt = tcp_v4_save_options(skb);
1321 1326
1322 if (security_inet_conn_request(sk, skb, req)) 1327 if (security_inet_conn_request(sk, skb, req))
1323 goto drop_and_free; 1328 goto drop_and_free;