mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 10:40:15 +02:00 
			
		
		
		
	selftests: mptcp: explicitly tests aggregate counters
Update the existing sockopt test-case to do some basic checks on the newly added counters. Link: https://github.com/multipath-tcp/mptcp_net-next/issues/385 Signed-off-by: Paolo Abeni <pabeni@redhat.com> Reviewed-by: Matthieu Baerts <matthieu.baerts@tessares.net> Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
		
							parent
							
								
									38967f424b
								
							
						
					
					
						commit
						5dcff89e14
					
				
					 1 changed files with 26 additions and 1 deletions
				
			
		| 
						 | 
					@ -51,6 +51,11 @@ struct mptcp_info {
 | 
				
			||||||
	__u8	mptcpi_local_addr_used;
 | 
						__u8	mptcpi_local_addr_used;
 | 
				
			||||||
	__u8	mptcpi_local_addr_max;
 | 
						__u8	mptcpi_local_addr_max;
 | 
				
			||||||
	__u8	mptcpi_csum_enabled;
 | 
						__u8	mptcpi_csum_enabled;
 | 
				
			||||||
 | 
						__u32	mptcpi_retransmits;
 | 
				
			||||||
 | 
						__u64	mptcpi_bytes_retrans;
 | 
				
			||||||
 | 
						__u64	mptcpi_bytes_sent;
 | 
				
			||||||
 | 
						__u64	mptcpi_bytes_received;
 | 
				
			||||||
 | 
						__u64	mptcpi_bytes_acked;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct mptcp_subflow_data {
 | 
					struct mptcp_subflow_data {
 | 
				
			||||||
| 
						 | 
					@ -83,8 +88,10 @@ struct mptcp_subflow_addrs {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct so_state {
 | 
					struct so_state {
 | 
				
			||||||
	struct mptcp_info mi;
 | 
						struct mptcp_info mi;
 | 
				
			||||||
 | 
						struct mptcp_info last_sample;
 | 
				
			||||||
	uint64_t mptcpi_rcv_delta;
 | 
						uint64_t mptcpi_rcv_delta;
 | 
				
			||||||
	uint64_t tcpi_rcv_delta;
 | 
						uint64_t tcpi_rcv_delta;
 | 
				
			||||||
 | 
						bool pkt_stats_avail;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifndef MIN
 | 
					#ifndef MIN
 | 
				
			||||||
| 
						 | 
					@ -322,8 +329,9 @@ static void do_getsockopt_mptcp_info(struct so_state *s, int fd, size_t w)
 | 
				
			||||||
	if (ret < 0)
 | 
						if (ret < 0)
 | 
				
			||||||
		die_perror("getsockopt MPTCP_INFO");
 | 
							die_perror("getsockopt MPTCP_INFO");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	assert(olen == sizeof(i));
 | 
						s->pkt_stats_avail = olen >= sizeof(i);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						s->last_sample = i;
 | 
				
			||||||
	if (s->mi.mptcpi_write_seq == 0)
 | 
						if (s->mi.mptcpi_write_seq == 0)
 | 
				
			||||||
		s->mi = i;
 | 
							s->mi = i;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -562,6 +570,23 @@ static void process_one_client(int fd, int pipefd)
 | 
				
			||||||
	do_getsockopts(&s, fd, ret, ret2);
 | 
						do_getsockopts(&s, fd, ret, ret2);
 | 
				
			||||||
	if (s.mptcpi_rcv_delta != (uint64_t)ret + 1)
 | 
						if (s.mptcpi_rcv_delta != (uint64_t)ret + 1)
 | 
				
			||||||
		xerror("mptcpi_rcv_delta %" PRIu64 ", expect %" PRIu64, s.mptcpi_rcv_delta, ret + 1, s.mptcpi_rcv_delta - ret);
 | 
							xerror("mptcpi_rcv_delta %" PRIu64 ", expect %" PRIu64, s.mptcpi_rcv_delta, ret + 1, s.mptcpi_rcv_delta - ret);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/* be nice when running on top of older kernel */
 | 
				
			||||||
 | 
						if (s.pkt_stats_avail) {
 | 
				
			||||||
 | 
							if (s.last_sample.mptcpi_bytes_sent != ret2)
 | 
				
			||||||
 | 
								xerror("mptcpi_bytes_sent %" PRIu64 ", expect %" PRIu64,
 | 
				
			||||||
 | 
								       s.last_sample.mptcpi_bytes_sent, ret2,
 | 
				
			||||||
 | 
								       s.last_sample.mptcpi_bytes_sent - ret2);
 | 
				
			||||||
 | 
							if (s.last_sample.mptcpi_bytes_received != ret)
 | 
				
			||||||
 | 
								xerror("mptcpi_bytes_received %" PRIu64 ", expect %" PRIu64,
 | 
				
			||||||
 | 
								       s.last_sample.mptcpi_bytes_received, ret,
 | 
				
			||||||
 | 
								       s.last_sample.mptcpi_bytes_received - ret);
 | 
				
			||||||
 | 
							if (s.last_sample.mptcpi_bytes_acked != ret)
 | 
				
			||||||
 | 
								xerror("mptcpi_bytes_acked %" PRIu64 ", expect %" PRIu64,
 | 
				
			||||||
 | 
								       s.last_sample.mptcpi_bytes_acked, ret2,
 | 
				
			||||||
 | 
								       s.last_sample.mptcpi_bytes_acked - ret2);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	close(fd);
 | 
						close(fd);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue