(OK) Android-x86-7.1.1/ kernel 4.4.62 - quagga - MIMP - 7 (mptcp_fullmesh.c)

gedit kernel/net/mptcp/mptcp_fullmesh.c

static void full_mesh_new_session(const struct sock *meta_sk)
{
	struct mptcp_loc_addr *mptcp_local;
	struct mptcp_cb *mpcb = tcp_sk(meta_sk)->mpcb;
	struct fullmesh_priv *fmp = fullmesh_get_priv(mpcb);
	const struct mptcp_fm_ns *fm_ns = fm_get_ns(sock_net(meta_sk));
	struct tcp_sock *master_tp = tcp_sk(mpcb->master_sk);
	int i, index, if_idx;
	union inet_addr saddr, daddr;
	sa_family_t family;
	bool meta_v4 = meta_sk->sk_family == AF_INET;

	/* Init local variables necessary for the rest */
	if (meta_sk->sk_family == AF_INET || mptcp_v6_is_v4_mapped(meta_sk)) {
		saddr.ip = inet_sk(meta_sk)->inet_saddr;
		daddr.ip = inet_sk(meta_sk)->inet_daddr;
		if_idx = mpcb->master_sk->sk_bound_dev_if;
		family = AF_INET;
#if IS_ENABLED(CONFIG_IPV6)
	} else {
		saddr.in6 = inet6_sk(meta_sk)->saddr;
		daddr.in6 = meta_sk->sk_v6_daddr;
		if_idx = mpcb->master_sk->sk_bound_dev_if;
		family = AF_INET6;
#endif
	}

	rcu_read_lock();
	mptcp_local = rcu_dereference(fm_ns->local);

	index = mptcp_find_address(mptcp_local, family, &saddr, if_idx);
	if (index < 0)
		goto fallback;

	if (family == AF_INET)
		master_tp->mptcp->low_prio = mptcp_local->locaddr4[index].low_prio;
	else
		master_tp->mptcp->low_prio = mptcp_local->locaddr6[index].low_prio;
	master_tp->mptcp->send_mp_prio = master_tp->mptcp->low_prio;

	full_mesh_add_raddr(mpcb, &daddr, family, 0, 0);
	mptcp_set_init_addr_bit(mpcb, &daddr, family, index);

//ztg add
//*
printk(KERN_INFO "mptcp: full_mesh_new_session: i = %u\n", mptcp_local->loc4_bits);
printk(KERN_INFO "mptcp: full_mesh_new_session: locaddr0 = %u\n", mptcp_local->locaddr4[0].addr.s_addr);
printk(KERN_INFO "mptcp: full_mesh_new_session: locaddr1 = %u\n", mptcp_local->locaddr4[1].addr.s_addr);
printk(KERN_INFO "mptcp: full_mesh_new_session: locaddr2 = %u\n", mptcp_local->locaddr4[2].addr.s_addr);
printk(KERN_INFO "mptcp: full_mesh_new_session: locaddr3 = %u\n", mptcp_local->locaddr4[3].addr.s_addr);
printk(KERN_INFO "mptcp: full_mesh_new_session: locaddr4 = %u\n", mptcp_local->locaddr4[4].addr.s_addr);
printk(KERN_INFO "mptcp: full_mesh_new_session: locaddr5 = %u\n", mptcp_local->locaddr4[5].addr.s_addr);
printk(KERN_INFO "mptcp: full_mesh_new_session: locaddr6 = %u\n", mptcp_local->locaddr4[6].addr.s_addr);
printk(KERN_INFO "mptcp: full_mesh_new_session: locaddr7 = %u\n", mptcp_local->locaddr4[7].addr.s_addr);
//*/

	/* Initialize workqueue-struct */
	INIT_WORK(&fmp->subflow_work, create_subflow_worker);
	INIT_DELAYED_WORK(&fmp->subflow_retry_work, retry_subflow_worker);
	fmp->mpcb = mpcb;
// ...
}

static void create_subflow_worker(struct work_struct *work)
{
	struct fullmesh_priv *fmp = container_of(work, struct fullmesh_priv,
						 subflow_work);
	struct mptcp_cb *mpcb = fmp->mpcb;
	struct sock *meta_sk = mpcb->meta_sk;
	struct mptcp_loc_addr *mptcp_local;
	const struct mptcp_fm_ns *fm_ns = fm_get_ns(sock_net(meta_sk));
	int iter = 0, retry = 0;
	int i;

	/* We need a local (stable) copy of the address-list. Really, it is not
	 * such a big deal, if the address-list is not 100% up-to-date.
	 */
	rcu_read_lock_bh();
	mptcp_local = rcu_dereference_bh(fm_ns->local);
	mptcp_local = kmemdup(mptcp_local, sizeof(*mptcp_local), GFP_ATOMIC);
	rcu_read_unlock_bh();

	if (!mptcp_local)
		return;

next_subflow:
	if (iter) {
		release_sock(meta_sk);
		mutex_unlock(&mpcb->mpcb_mutex);

		cond_resched();
	}
	mutex_lock(&mpcb->mpcb_mutex);
	lock_sock_nested(meta_sk, SINGLE_DEPTH_NESTING);

	/* Create the additional subflows for the first pair */
	if (fmp->first_pair == 0 && mpcb->master_sk) {
		struct mptcp_loc4 loc;
		struct mptcp_rem4 rem;

		loc.addr.s_addr = inet_sk(meta_sk)->inet_saddr;
		loc.loc4_id = 0;
		loc.low_prio = 0;
		loc.if_idx = mpcb->master_sk->sk_bound_dev_if;

		rem.addr.s_addr = inet_sk(meta_sk)->inet_daddr;
		rem.port = inet_sk(meta_sk)->inet_dport;
		rem.rem4_id = 0; /* Default 0 */

		mptcp_v4_subflows(meta_sk, &loc, &rem);

		fmp->first_pair = 1;
	}
	iter++;

	if (sock_flag(meta_sk, SOCK_DEAD))
		goto exit;

	if (mpcb->master_sk &&
	    !tcp_sk(mpcb->master_sk)->mptcp->fully_established)
		goto exit;

/*
112.26.0.1 (16783984)
112.26.1.1 (16849520)
112.26.2.1 (16915056)
112.26.3.1 (16980592)
112.26.4.1 (17046128)

112.26.0.6 (100670064)
112.26.1.6 (100735600)
112.26.2.6 (100801136)
112.26.3.6 (100866672)
112.26.4.6 (100932208)
*/

//ztg add
/*
printk(KERN_INFO "mptcp: create_subflow_worker: i = %u\n", fmp->rem4_bits);
printk(KERN_INFO "mptcp: create_subflow_worker: remaddr0 = %u\n", fmp->remaddr4[0].addr.s_addr);
printk(KERN_INFO "mptcp: create_subflow_worker: remaddr1 = %u\n", fmp->remaddr4[1].addr.s_addr);
printk(KERN_INFO "mptcp: create_subflow_worker: remaddr2 = %u\n", fmp->remaddr4[2].addr.s_addr);
printk(KERN_INFO "mptcp: create_subflow_worker: remaddr3 = %u\n", fmp->remaddr4[3].addr.s_addr);
printk(KERN_INFO "mptcp: create_subflow_worker: remaddr4 = %u\n", fmp->remaddr4[4].addr.s_addr);
printk(KERN_INFO "mptcp: create_subflow_worker: remaddr5 = %u\n", fmp->remaddr4[5].addr.s_addr);
printk(KERN_INFO "mptcp: create_subflow_worker: remaddr6 = %u\n", fmp->remaddr4[6].addr.s_addr);
printk(KERN_INFO "mptcp: create_subflow_worker: remaddr7 = %u\n", fmp->remaddr4[7].addr.s_addr);
//*/
printk(KERN_INFO "mptcp: create_subflow_worker: next_subflow\n");

	mptcp_for_each_bit_set(fmp->rem4_bits, i) {
		struct fullmesh_rem4 *rem;
		u8 remaining_bits;

		rem = &fmp->remaddr4[i];
		remaining_bits = ~(rem->bitfield) & mptcp_local->loc4_bits;

		/* Are there still combinations to handle? */
		if (remaining_bits) {
			int i = mptcp_find_free_index(~remaining_bits);
			struct mptcp_rem4 rem4;

			rem->bitfield |= (1 << i);

			rem4.addr = rem->addr;
			rem4.port = rem->port;
			rem4.rem4_id = rem->rem4_id;
//ztg add
//printk(KERN_INFO "mptcp: create_subflow_worker: i = %u\n", remaining_bits);
//printk(KERN_INFO "mptcp: create_subflow_worker: locaddr%d = %u\n", i, mptcp_local->locaddr4[i].addr.s_addr);
printk(KERN_INFO "mptcp: create_subflow_worker: locaddr = %u --- remaddr = %u\n", mptcp_local->locaddr4[i].addr.s_addr, rem4.addr.s_addr);

			/* If a route is not yet available then retry once */
			if (mptcp_init4_subsockets(meta_sk, &mptcp_local->locaddr4[i],
						   &rem4) == -ENETUNREACH)
				retry = rem->retry_bitfield |= (1 << i);
			else
				mptcp_v4_subflows(meta_sk,
						  &mptcp_local->locaddr4[i],
						  &rem4);
			goto next_subflow;
		}
	}
// ...
}


posted @ 2017-07-01 23:16  张同光  阅读(141)  评论(0编辑  收藏  举报