标签:
"net/mptcp/mptcp_ipv4.c" line 328 of 488 328 int mptcp_init4_subsockets(struct sock *meta_sk, const struct mptcp_loc4 *loc, 329 struct mptcp_rem4 *rem) 330 { 331 struct tcp_sock *tp; 332 struct sock *sk; 333 struct sockaddr_in loc_in, rem_in; 334 struct socket sock; 335 int ulid_size = 0, ret; 336 337 /** First, create and prepare the new socket */ 338 339 sock.type = meta_sk->sk_socket->type; 340 sock.state = SS_UNCONNECTED; 341 sock.wq = meta_sk->sk_socket->wq; 342 sock.file = meta_sk->sk_socket->file; 343 sock.ops = NULL; 344 345 ret = inet_create(sock_net(meta_sk), &sock, IPPROTO_TCP, 1); 346 if (unlikely(ret < 0)) { 347 mptcp_debug("%s inet_create failed ret: %d\n", __func__, ret); 348 return ret; 349 } 350 351 sk = sock.sk; 352 tp = tcp_sk(sk);
354 /* All subsockets need the MPTCP-lock-class */ 355 lockdep_set_class_and_name(&(sk)->sk_lock.slock, &meta_slock_key, "slock-AF_INET-MPTCP"); 356 lockdep_init_map(&(sk)->sk_lock.dep_map, "sk_lock-AF_INET-MPTCP", &meta_key, 0); 357 358 if (mptcp_add_sock(meta_sk, sk, loc->loc4_id, rem->rem4_id, GFP_KERNEL)) 359 goto error; 360 361 tp->mptcp->slave_sk = 1; 362 tp->mptcp->low_prio = loc->low_prio; 363 364 /* Initializing the timer for an MPTCP subflow */ 365 setup_timer(&tp->mptcp->mptcp_ack_timer, mptcp_ack_handler, (unsigned long)sk);
368 369 ulid_size = sizeof(struct sockaddr_in); 370 loc_in.sin_family = AF_INET; 371 rem_in.sin_family = AF_INET; 372 loc_in.sin_port = 0; 373 if (rem->port) 374 rem_in.sin_port = rem->port; 375 else 376 rem_in.sin_port = inet_sk(meta_sk)->inet_dport; 377 loc_in.sin_addr = loc->addr; 378 rem_in.sin_addr = rem->addr; 379 380 ret = sock.ops->bind(&sock, (struct sockaddr *)&loc_in, ulid_size); 381 if (ret < 0) { 382 mptcp_debug("%s: MPTCP subsocket bind() failed, error %d\n", 383 __func__, ret); 384 goto error; 385 } 386 387 mptcp_debug("%s: token %#x pi %d src_addr:%pI4:%d dst_addr:%pI4:%d\n", 388 __func__, tcp_sk(meta_sk)->mpcb->mptcp_loc_token, 389 tp->mptcp->path_index, &loc_in.sin_addr, 390 ntohs(loc_in.sin_port), &rem_in.sin_addr, 391 ntohs(rem_in.sin_port)); 392 393 if (tcp_sk(meta_sk)->mpcb->pm_ops->init_subsocket_v4) 394 tcp_sk(meta_sk)->mpcb->pm_ops->init_subsocket_v4(sk, rem->addr); 395 396 ret = sock.ops->connect(&sock, (struct sockaddr *)&rem_in, 397 ulid_size, O_NONBLOCK); 398 if (ret < 0 && ret != -EINPROGRESS) { 399 mptcp_debug("%s: MPTCP subsocket connect() failed, error %d\n", 400 __func__, ret); 401 goto error; 402 }
403 404 sk_set_socket(sk, meta_sk->sk_socket); 405 sk->sk_wq = meta_sk->sk_wq; 406 407 return 0; 408 409 error: 410 /* May happen if mptcp_add_sock fails first */ 411 if (!mptcp(tp)) { 412 tcp_close(sk, 0); 413 } else { 414 local_bh_disable(); 415 mptcp_sub_force_close(sk); 416 local_bh_enable(); 417 } 418 return ret; 419 }
"net/ipv4/tcp_minisocks.c" line 766 of 872 760 /* OK, ACK is valid, create big socket and 761 * feed this segment to it. It will repeat all 762 * the tests. THIS SEGMENT MUST MOVE SOCKET TO 763 * ESTABLISHED STATE. If it will be dropped after 764 * socket is created, wait for troubles. 765 */ 766 #ifdef CONFIG_MPTCP 767 if (mptcp(tcp_sk(sk))) 768 /* MPTCP: We call the mptcp-specific syn_recv_sock */ 769 child = tcp_sk(sk)->mpcb->syn_recv_sock(sk, skb, req, NULL); 770 else 771 #endif 772 child = inet_csk(sk)->icsk_af_ops->syn_recv_sock(sk, skb, 773 req, NULL); 774 775 if (child == NULL) 776 goto listen_overflow;
标签:
原文地址:http://www.cnblogs.com/lxgeek/p/4329986.html