Skip to content

include/sys/socket.h: Add SOCK_CTRL to socket type#8370

Merged
xiaoxiang781216 merged 1 commit into
apache:masterfrom
SPRESENSE:pullrequest-658
Feb 8, 2023
Merged

include/sys/socket.h: Add SOCK_CTRL to socket type#8370
xiaoxiang781216 merged 1 commit into
apache:masterfrom
SPRESENSE:pullrequest-658

Conversation

@SPRESENSE
Copy link
Copy Markdown
Contributor

Summary

SOCK_CTRL is added to provide special control over network drivers and daemons. Currently, SOCK_DGRAM and SOCK_STREAM perform this control, but these use socket resources. In the case of usersocket in particular, this is a waste of the device's limited socket resources.

Impact

Applications using NET_SOCK_TYPE.

Testing

SPRESENSE LTE board.

@xiaoxiang781216
Copy link
Copy Markdown
Contributor

@SPRESENSE but how to pass the ioctl to usrsock server now?

@SPRESENSE
Copy link
Copy Markdown
Contributor Author

SPRESENSE commented Feb 6, 2023

Dear @xiaoxiang781216 san

@SPRESENSE but how to pass the ioctl to usrsock server now?

This fix only add a new Socket Type for requests to Daemons that do not use the device's Socket.
Therefore, the PASS method to usrsock server will remain the same.

@xiaoxiang781216
Copy link
Copy Markdown
Contributor

Dear @xiaoxiang781216 san

@SPRESENSE but how to pass the ioctl to usrsock server now?

This fix only add a new Socket Type for requests to Daemons that do not use the device's Socket. Therefore, the PASS method to usrsock server will remain the same.

Ok, I saw SOCK_CTRL will convert to the real type:
https://github.com/apache/nuttx/pull/8370/files#diff-098d0f88e64dc86480d735d351725fce63ff53c8b0d834ca460ba61c2eb9bb13R289-R304
So, what's the benefit to add SOCK_CTRL?

@SPRESENSE
Copy link
Copy Markdown
Contributor Author

Dear @xiaoxiang781216 san

Dear @xiaoxiang781216 san

@SPRESENSE but how to pass the ioctl to usrsock server now?

This fix only add a new Socket Type for requests to Daemons that do not use the device's Socket. Therefore, the PASS method to usrsock server will remain the same.

Ok, I saw SOCK_CTRL will convert to the real type: https://github.com/apache/nuttx/pull/8370/files#diff-098d0f88e64dc86480d735d351725fce63ff53c8b0d834ca460ba61c2eb9bb13R289-R304 So, what's the benefit to add SOCK_CTRL?

The benefit of this change is that Daemon can determine not to consume Socket resources for devices that should not consume them.(e.g. One of modem as ALT1250 can use 5 internal socket only.)
By adding the type SOCK_CTRL and specifying that type in the Socket for requests such as the ifup command or ifconfig command, Daemon will know not to open the Socket for the device. So Daemon can receive SOCK_CTRL to prevent the device from consuming Socket resources by not opening the Socket for the device.

@xiaoxiang781216
Copy link
Copy Markdown
Contributor

xiaoxiang781216 commented Feb 7, 2023

Dear @xiaoxiang781216 san

Dear @xiaoxiang781216 san

@SPRESENSE but how to pass the ioctl to usrsock server now?

This fix only add a new Socket Type for requests to Daemons that do not use the device's Socket. Therefore, the PASS method to usrsock server will remain the same.

Ok, I saw SOCK_CTRL will convert to the real type: https://github.com/apache/nuttx/pull/8370/files#diff-098d0f88e64dc86480d735d351725fce63ff53c8b0d834ca460ba61c2eb9bb13R289-R304 So, what's the benefit to add SOCK_CTRL?

The benefit of this change is that Daemon can determine not to consume Socket resources for devices that should not consume them.(e.g. One of modem as ALT1250 can use 5 internal socket only.) By adding the type SOCK_CTRL and specifying that type in the Socket for requests such as the ifup command or ifconfig command, Daemon will know not to open the Socket for the device. So Daemon can receive SOCK_CTRL to prevent the device from consuming Socket resources by not opening the Socket for the device.

Ok, so the patch tries to reduce the driver consumption, but not the nework stack self. Look reasonable, thanks, then let's fix the CI error.

@xiaoxiang781216
Copy link
Copy Markdown
Contributor

xiaoxiang781216 commented Feb 7, 2023

@Shunichi-K please merge the intermediate change into the first patch.

@SPRESENSE
Copy link
Copy Markdown
Contributor Author

Dear @xiaoxiang781216 san

Sure. I updated a commit now.

Comment thread include/nuttx/net/netconfig.h Outdated
SOCK_CTRL is added to provide special control over network drivers
and daemons. Currently, SOCK_DGRAM and SOCK_STREAM perform this control,
but these use socket resources. In the case of usersocket in particular,
this is a waste of the device's limited socket resources.
@xiaoxiang781216 xiaoxiang781216 merged commit abba05a into apache:master Feb 8, 2023
@masayuki2009
Copy link
Copy Markdown
Contributor

masayuki2009 commented Feb 8, 2023

@SPRESENSE @xiaoxiang781216
Hmm, l noticed that lm3s6965-ek:discover (QEMU) does not work with this PR.
It seems that no network interface is found.

NuttShell (NSH) NuttX-10.4.0
nsh> uname -a
NuttX  10.4.0 abba05a934 Feb  8 2023 22:35:51 arm lm3s6965-ek
nsh> ps
  PID GROUP PRI POLICY   TYPE    NPX STATE    EVENT     SIGMASK   STACK   USED  FILLED COMMAND
    0     0   0 FIFO     Kthread N-- Ready              00000000 001000 000464  46.4%  Idle Task
    1     1 224 RR       Kthread --- Waiting  Semaphore 00000000 001992 000276  13.8%  hpwork 0x20001cd0
    2     2  60 RR       Kthread --- Waiting  Semaphore 00000000 001992 000276  13.8%  lpwork 0x20001ce8
    3     3 100 RR       Task    --- Running            00000000 002000 001168  58.4%  nsh_main
    4     4 100 RR       Task    --- Waiting  Semaphore 00000000 002008 000564  28.0%  telnetd
nsh> free
                   total       used       free    largest  nused  nfree
        Umem:      49616      16560      33056      33056     61      1
nsh> ifconfig
             IPv4   TCP   UDP  ICMP
Received     0000  0000  0000  0000
Dropped      0000  0000  0000  0000
  IPv4        VHL: 0000   Frg: 0000
  Checksum   0000  0000  0000  ----
  TCP         ACK: 0000   SYN: 0000
              RST: 0000  0000
  Type       0000  ----  ----  0000
Sent         0000  0000  0000  0000
  Rexmit     ----  0000  ----  ----
nsh> renew eth0
ERROR: dhcpc_open() for 'eth0' failed
nsh> ifconfig
             IPv4   TCP   UDP  ICMP
Received     0000  0000  0000  0000
Dropped      0000  0000  0000  0000
  IPv4        VHL: 0000   Frg: 0000
  Checksum   0000  0000  0000  ----
  TCP         ACK: 0000   SYN: 0000
              RST: 0000  0000
  Type       0000  ----  ----  0000
Sent         0000  0000  0000  0000
  Rexmit     ----  0000  ----  ----

@masayuki2009
Copy link
Copy Markdown
Contributor

Let me revert this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants