netutils/dhcpc: Set BOOTP BROADCAST flag when IPFORWARD is enabled
Socket binded to INADDR_ANY is not intended to receive unicast traffic before being fully configured, at least dhclient configured with socket-only won't do so on Linux and BSDs (https://github.com/isc-projects/dhcp/blob/v4_4_3/common/socket.c#L1201). We can sometimes receive unicast traffic before being fully configured, it's good, but not always, so we need to set the broadcast flag under some situations. Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
This commit is contained in:
parent
400951b7de
commit
3e68694bdf
@ -32,10 +32,15 @@ config NETUTILS_DHCPC_RETRIES
|
|||||||
|
|
||||||
config NETUTILS_DHCPC_BOOTP_FLAGS
|
config NETUTILS_DHCPC_BOOTP_FLAGS
|
||||||
hex "Flags of Bootstrap"
|
hex "Flags of Bootstrap"
|
||||||
default 0x0000
|
default 0x0000 if !NET_IPFORWARD
|
||||||
|
default 0x8000 if NET_IPFORWARD
|
||||||
---help---
|
---help---
|
||||||
This setting to set the BOOTP broadcast flags.
|
This setting to set the BOOTP broadcast flags.
|
||||||
Reference RFC1542: Clarifications and Extensions for the
|
Reference RFC1542: Clarifications and Extensions for the
|
||||||
Bootstrap Protocol.
|
Bootstrap Protocol.
|
||||||
|
|
||||||
|
Note: We're not always able to receive unicast traffic before
|
||||||
|
being fully configured, e.g. with forward enabled. Then we need
|
||||||
|
to enable the broadcast flag under these situations.
|
||||||
|
|
||||||
endif
|
endif
|
||||||
|
@ -267,8 +267,12 @@ static int dhcpc_sendmsg(FAR struct dhcpc_state_s *pdhcpc,
|
|||||||
/* Broadcast DISCOVER message to all servers */
|
/* Broadcast DISCOVER message to all servers */
|
||||||
|
|
||||||
case DHCPDISCOVER:
|
case DHCPDISCOVER:
|
||||||
/* REVISIT: We don't need the broadcast flag since we can receive
|
/* Socket binded to INADDR_ANY is not intended to receive unicast
|
||||||
* unicast traffic before being fully configured.
|
* traffic before being fully configured, at least dhclient
|
||||||
|
* configured with socket-only won't do so on Linux and BSDs.
|
||||||
|
* We can sometimes receive unicast traffic before being fully
|
||||||
|
* configured, it's good, but not always, so we need to set the
|
||||||
|
* broadcast flag under some situations.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Broadcast bit. */
|
/* Broadcast bit. */
|
||||||
@ -283,9 +287,6 @@ static int dhcpc_sendmsg(FAR struct dhcpc_state_s *pdhcpc,
|
|||||||
/* Send REQUEST message to the server that sent the *first* OFFER */
|
/* Send REQUEST message to the server that sent the *first* OFFER */
|
||||||
|
|
||||||
case DHCPREQUEST:
|
case DHCPREQUEST:
|
||||||
/* REVISIT: We don't need the broadcast flag since we can receive
|
|
||||||
* unicast traffic before being fully configured.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Broadcast bit. */
|
/* Broadcast bit. */
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user