[Crash-utility] [patch crash v2 2/2] namespace support for net command

Dave Anderson anderson at redhat.com
Thu Dec 4 19:12:55 UTC 2014



----- Original Message -----
> net without arguments shows network devices in init_net
> net -n  --  in network namespace of current task
> net -n pid|taskp -- in network namespace of specified task
> 
> Signed-off-by: Vasily Averin <vvs at openvz.org>

... [ cut ] ...

>  static void
> -show_net_devices_v3(void)
> +show_net_devices_v3(ulong task)
>  {
> +	ulong nsproxy_p, net_ns_p;
>  	struct list_data list_data, *ld;
>  	char *net_device_buf;
>  	char buf[BUFSIZE];
> @@ -523,8 +542,15 @@ show_net_devices_v3(void)
>  	ld =  &list_data;
>  	BZERO(ld, sizeof(struct list_data));
>  	ld->flags |= LIST_ALLOCATE;
> -	ld->start = ld->end =
> -		 symbol_value("init_net") + OFFSET(net_dev_base_head);
> +	if (VALID_MEMBER(task_struct_nsproxy)) {
> +		readmem(task + OFFSET(task_struct_nsproxy), KVADDR, &nsproxy_p,
> +			sizeof(ulong), "task_struct.nsproxy", FAULT_ON_ERROR);
> +		if (!readmem(nsproxy_p + OFFSET(nsproxy_net_ns), KVADDR, &net_ns_p,
> +			sizeof(ulong), "nsproxy.net_ns", RETURN_ON_ERROR|QUIET))
> +			error(FATAL, "cannot determine net_namespace location!\n");
> +	} else
> +		net_ns_p = symbol_value("init_net");
> +	ld->start = ld->end = net_ns_p + OFFSET(net_dev_base_head);
>  	ld->list_head_offset = OFFSET(net_device_dev_list);

Shouldn't the VALID_MEMBER test above be for nsproxy.net_ns?
It looks task_struct.nsproxy was introduced in 2.6.19, but
nsproxy.net_ns didn't come along until 2.6.24.

Dave




More information about the Crash-utility mailing list