Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net_tstamp: Add SIOCGHWTSTAMP ioctl to match SIOCSHWTSTAMP

SIOCSHWTSTAMP returns the real configuration to the application
using it, but there is currently no way for any other
application to find out the configuration non-destructively.
Add a new ioctl for this, making it unprivileged.

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>

+19 -10
+7 -2
Documentation/networking/timestamping.txt
··· 85 85 by the network device and will be empty without that support. 86 86 87 87 88 - SIOCSHWTSTAMP: 88 + SIOCSHWTSTAMP, SIOCGHWTSTAMP: 89 89 90 90 Hardware time stamping must also be initialized for each device driver 91 91 that is expected to do hardware time stamping. The parameter is defined in ··· 114 114 Only a processes with admin rights may change the configuration. User 115 115 space is responsible to ensure that multiple processes don't interfere 116 116 with each other and that the settings are reset. 117 + 118 + Any process can read the actual configuration by passing this 119 + structure to ioctl(SIOCGHWTSTAMP) in the same way. However, this has 120 + not been implemented in all drivers. 117 121 118 122 /* possible values for hwtstamp_config->tx_type */ 119 123 enum { ··· 161 157 162 158 A driver which supports hardware time stamping must support the 163 159 SIOCSHWTSTAMP ioctl and update the supplied struct hwtstamp_config with 164 - the actual values as described in the section on SIOCSHWTSTAMP. 160 + the actual values as described in the section on SIOCSHWTSTAMP. It 161 + should also support SIOCGHWTSTAMP. 165 162 166 163 Time stamps for received packets must be stored in the skb. To get a pointer 167 164 to the shared time stamp structure of the skb call skb_hwtstamps(). Then
+7 -7
include/uapi/linux/net_tstamp.h
··· 26 26 }; 27 27 28 28 /** 29 - * struct hwtstamp_config - %SIOCSHWTSTAMP parameter 29 + * struct hwtstamp_config - %SIOCGHWTSTAMP and %SIOCSHWTSTAMP parameter 30 30 * 31 - * @flags: no flags defined right now, must be zero 31 + * @flags: no flags defined right now, must be zero for %SIOCSHWTSTAMP 32 32 * @tx_type: one of HWTSTAMP_TX_* 33 33 * @rx_filter: one of HWTSTAMP_FILTER_* 34 34 * 35 - * %SIOCSHWTSTAMP expects a &struct ifreq with a ifr_data pointer to 36 - * this structure. If the driver or hardware does not support the 37 - * requested @rx_filter value, the driver may use a more general 38 - * filter mode. In this case @rx_filter will indicate the actual mode 39 - * on return. 35 + * %SIOCGHWTSTAMP and %SIOCSHWTSTAMP expect a &struct ifreq with a 36 + * ifr_data pointer to this structure. For %SIOCSHWTSTAMP, if the 37 + * driver or hardware does not support the requested @rx_filter value, 38 + * the driver may use a more general filter mode. In this case 39 + * @rx_filter will indicate the actual mode on return. 40 40 */ 41 41 struct hwtstamp_config { 42 42 int flags;
+2 -1
include/uapi/linux/sockios.h
··· 125 125 #define SIOCBRDELIF 0x89a3 /* remove interface from bridge */ 126 126 127 127 /* hardware time stamping: parameters in linux/net_tstamp.h */ 128 - #define SIOCSHWTSTAMP 0x89b0 128 + #define SIOCSHWTSTAMP 0x89b0 /* set and get config */ 129 + #define SIOCGHWTSTAMP 0x89b1 /* get config */ 129 130 130 131 /* Device private ioctl calls */ 131 132
+2
net/core/dev_ioctl.c
··· 327 327 cmd == SIOCBRADDIF || 328 328 cmd == SIOCBRDELIF || 329 329 cmd == SIOCSHWTSTAMP || 330 + cmd == SIOCGHWTSTAMP || 330 331 cmd == SIOCWANDEV) { 331 332 err = -EOPNOTSUPP; 332 333 if (ops->ndo_do_ioctl) { ··· 547 546 */ 548 547 default: 549 548 if (cmd == SIOCWANDEV || 549 + cmd == SIOCGHWTSTAMP || 550 550 (cmd >= SIOCDEVPRIVATE && 551 551 cmd <= SIOCDEVPRIVATE + 15)) { 552 552 dev_load(net, ifr.ifr_name);
+1
net/socket.c
··· 3231 3231 case SIOCBONDSLAVEINFOQUERY: 3232 3232 case SIOCBONDINFOQUERY: 3233 3233 case SIOCSHWTSTAMP: 3234 + case SIOCGHWTSTAMP: 3234 3235 return compat_ifr_data_ioctl(net, cmd, argp); 3235 3236 3236 3237 case FIOSETOWN: