Wireshark-dev: Re: [Wireshark-dev] tshark fails to capture packet on IB interface
From: Guy Harris <guy@xxxxxxxxxxxx>
Date: Wed, 20 Sep 2006 00:32:04 -0700
Guy Harris wrote:

No, because I don't have the Linux kernel source handy at present, but what you want to do is edit net/core/dev.c, look for "case SIOCGIFHWADDR:" somewhere around line 2362, and change the code to do

Actually, the existing code already refuses to copy more than "sizeof ifr->ifr_hwaddr.sa_data" bytes, so you might just want to take the patch at

	http://oss.oracle.com/projects/rhel4kernels/src/mainline/current/SOURCES/linux-2.6.9-net-SIOCGIFHWADDR-NULL-dev_addr.patch

and apply it to the Linux kernel with "patch -R", to back that patch out.

If you're ambitious, you could then change the code to

		case SIOCGIFHWADDR:
			if (!dev->addr_len)
				memset(ifr->ifr_hwaddr.sa_data, 0, sizeof ifr->ifr_hwaddr.sa_data);
			else
				memcpy(ifr->ifr_hwaddr.sa_data, dev->dev_addr,
				       min(sizeof ifr->ifr_hwaddr.sa_data, (size_t) dev->addr_len));
			ifr->ifr_hwaddr.sa_family = dev->type;
			return 0;

(so as not to lose the "memset()").

Or just upgrade to a more recent kernel, such as 2.6.10, which *already* works like that - but don't pick up Red Hat's change that caused the ioctl to return an error.