All of lore.kernel.org
 help / color / mirror / Atom feed
From: Denis Kenzior <denkenz@gmail.com>
To: ell@lists.01.org
Subject: Re: [PATCH 05/20] dhcp-transport: modify BPF filter for server
Date: Fri, 16 Oct 2020 11:31:27 -0500	[thread overview]
Message-ID: <c93b61af-6e35-b2c1-2cfb-05abb2f36667@gmail.com> (raw)
In-Reply-To: <20201016153635.660391-5-prestwoj@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 2635 bytes --]

Hi James,

On 10/16/20 10:36 AM, James Prestwood wrote:
> In preparation for dhcp server the XID portion of the BPF
> needs to be skipped when the port is DHCP_PORT_SERVER since
> this value will not be present in messages going to the
> server. The check for the message op was also changed to
> include both BOOTREQUEST and BOOTREPLY depending if the
> port matches the server or client port.
> ---
>   ell/dhcp-transport.c | 8 +++++++-
>   ell/dhcp.c           | 3 +--
>   2 files changed, 8 insertions(+), 3 deletions(-)
> 
> v2:
>   * Maintained the check for BOOTREPLY while also filtering for
>     BOOTREQUEST in the server case
>   * Maintained the check for XID in the client case but skip
>     over this check for server.
> 
> diff --git a/ell/dhcp-transport.c b/ell/dhcp-transport.c
> index e332f99..b693530 100644
> --- a/ell/dhcp-transport.c
> +++ b/ell/dhcp-transport.c
> @@ -384,7 +384,9 @@ static int kernel_raw_socket_open(uint32_t ifindex, uint16_t port, uint32_t xid)
>   				offsetof(struct dhcp_packet, dhcp.op)),
>   		/* op == BOOTREPLY ? */

I updated the comment slightly here

>   		BPF_JUMP(BPF_JMP + BPF_JEQ + BPF_K,
> -				DHCP_OP_CODE_BOOTREPLY, 1, 0),
> +				(port == DHCP_PORT_CLIENT) ?
> +				DHCP_OP_CODE_BOOTREPLY :
> +				DHCP_OP_CODE_BOOTREQUEST, 1, 0),
>   		/* ignore */
>   		BPF_STMT(BPF_RET + BPF_K, 0),
>   		/* A <- DHCP header type */
> @@ -394,6 +396,10 @@ static int kernel_raw_socket_open(uint32_t ifindex, uint16_t port, uint32_t xid)
>   		BPF_JUMP(BPF_JMP + BPF_JEQ + BPF_K, ARPHRD_ETHER, 1, 0),
>   		/* ignore */
>   		BPF_STMT(BPF_RET + BPF_K, 0),
> +		/* A <- UDP destination port */
> +		BPF_STMT(BPF_LD + BPF_H + BPF_ABS,
> +				offsetof(struct dhcp_packet, udp.dest)),
> +		BPF_JUMP(BPF_JMP + BPF_JEQ + BPF_K, DHCP_PORT_SERVER, 3, 0),
>   		/* A <- client identifier */
>   		BPF_STMT(BPF_LD + BPF_W + BPF_ABS,
>   				offsetof(struct dhcp_packet, dhcp.xid)),
> diff --git a/ell/dhcp.c b/ell/dhcp.c
> index e604dc0..12ed505 100644
> --- a/ell/dhcp.c
> +++ b/ell/dhcp.c
> @@ -974,8 +974,7 @@ LIB_EXPORT bool l_dhcp_client_start(struct l_dhcp_client *client)
>   		l_getrandom(&client->xid, sizeof(client->xid));
>   
>   	if (client->transport->open)
> -		if (client->transport->open(client->transport,
> -							client->xid) < 0)
> +		if (client->transport->open(client->transport, client->xid) < 0)
>   			return false;
>   
>   	_dhcp_transport_set_rx_callback(client->transport,
> 

And I dropped this chunk since it was formatting only and not related to the change.

Applied, thanks.

Regards,
-Denis

  reply	other threads:[~2020-10-16 16:31 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-16 15:36 [PATCH 01/20] net: add l_net_get_address() James Prestwood
2020-10-16 15:36 ` [PATCH 02/20] dhcp-util: add dhcp message builder APIs James Prestwood
2020-10-16 15:36 ` [PATCH 03/20] dhcp: update client code to use " James Prestwood
2020-10-16 15:36 ` [PATCH 04/20] dhcp-util: move iter APIs to dhcp-util James Prestwood
2020-10-16 16:24   ` Denis Kenzior
2020-10-16 15:36 ` [PATCH 05/20] dhcp-transport: modify BPF filter for server James Prestwood
2020-10-16 16:31   ` Denis Kenzior [this message]
2020-10-16 15:36 ` [PATCH 06/20] dhcp-transport: rename 'broadcast' op to 'l2_send' James Prestwood
2020-10-16 15:36 ` [PATCH 07/20] unit: update test-dhcp to use l2_send James Prestwood
2020-10-16 15:36 ` [PATCH 08/20] dhcp-lease: add mac member and getter James Prestwood
2020-10-16 15:36 ` [PATCH 09/20] dhcp: prepare for DHCP server James Prestwood
2020-10-16 15:36 ` [PATCH 10/20] dhcp-server: basic DHCP server skeleton James Prestwood
2020-10-16 15:36 ` [PATCH 11/20] dhcp-server: add transport framework James Prestwood
2020-10-16 15:36 ` [PATCH 12/20] dhcp-server: process DISCOVER and send OFFER James Prestwood
2020-10-16 15:36 ` [PATCH 13/20] dhcp-server: add REQUEST processing James Prestwood
2020-10-16 15:36 ` [PATCH 14/20] dhcp-server: handle DECLINE messages James Prestwood
2020-10-16 15:36 ` [PATCH 15/20] dhcp-server: add RELEASE message support James Prestwood
2020-10-16 15:36 ` [PATCH 16/20] dhcp-server: add INFORM message handling James Prestwood
2020-10-16 15:36 ` [PATCH 17/20] unit: update dhcp test to use new builder APIs James Prestwood
2020-10-16 15:36 ` [PATCH 18/20] examples: basic DHCP server example James Prestwood
2020-10-16 15:36 ` [PATCH 19/20] unit: add complete client/server dhcp test James Prestwood
2020-10-16 15:36 ` [PATCH 20/20] dhcp: Add support for setting address James Prestwood

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c93b61af-6e35-b2c1-2cfb-05abb2f36667@gmail.com \
    --to=denkenz@gmail.com \
    --cc=ell@lists.01.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.