Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
net_ioctl [2018/09/03 16:26] – [Sample userspace call: ethtool] rpjdaynet_ioctl [2018/09/04 10:31] (current) – [send_ioctl()] rpjday
Line 20: Line 20:
 ===== Sample userspace call: ethtool ===== ===== Sample userspace call: ethtool =====
  
-Git repo is [[git://git.kernel.org/pub/scm/network/ethtool/ethtool.git|here]].+Git repo is [[https://git.kernel.org/pub/scm/network/ethtool/ethtool.git/|here]].
  
 ==== send_ioctl() ==== ==== send_ioctl() ====
Line 30: Line 30:
 int send_ioctl(struct cmd_context *ctx, void *cmd) int send_ioctl(struct cmd_context *ctx, void *cmd)
 { {
-        ctx->ifr.ifr_data = cmd;+        ctx->ifr.ifr_data = cmd;        // command-specific structure
         return ioctl(ctx->fd, SIOCETHTOOL, &ctx->ifr);         return ioctl(ctx->fd, SIOCETHTOOL, &ctx->ifr);
 } }
 #endif #endif
 </code> </code>
 +
 +QUESTION: What is returned in ifreq%%->%%cmd?
  
 ==== struct cmd_context ==== ==== struct cmd_context ====
Line 132: Line 134:
 ==== sock_ioctl() ==== ==== sock_ioctl() ====
  
-Also from ''net/socket.c'':+Also from ''net/socket.c'' -- anything related to ''SIOCDEVPRIVATE'' is seriously deprecated (see [[https://elixir.bootlin.com/linux/latest/source/include/uapi/linux/sockios.h#L135|here]]):
  
 <code> <code>
Line 156: Line 158:
                                 return -EFAULT;                                 return -EFAULT;
         } else         } else
 +</code>
 +
 +This reflects wireless extensions, which should not be relevant:
 +
 +<code>
 #ifdef CONFIG_WEXT_CORE #ifdef CONFIG_WEXT_CORE
         if (cmd >= SIOCIWFIRST && cmd <= SIOCIWLAST) {         if (cmd >= SIOCIWFIRST && cmd <= SIOCIWLAST) {
Line 161: Line 168:
         } else         } else
 #endif #endif
 +</code>
 +
 +Finally, this is where we should end up:
 +
 +<code>
                 switch (cmd) {                 switch (cmd) {
                 case FIOSETOWN:                 case FIOSETOWN:
  • net_ioctl.1535991961.txt.gz
  • Last modified: 2018/09/03 16:26
  • by rpjday