suricatta: added option to bind to interface/IP address.
diff mbox series

Message ID 1581581030-29912-1-git-send-email-luca.pesce@vimar.com
State Changes Requested
Headers show
Series
  • suricatta: added option to bind to interface/IP address.
Related show

Commit Message

Pesce Luca Feb. 13, 2020, 8:03 a.m. UTC
This patch adds the -f cmdline arg and the "interface" parameter to suricatta
to optionally bind communication channel to a specific interface or IP address.
To do so, a new config option is added to curl channel interface, which then
exploits CURLOPT_INTERFACE option.
Binding to an interface is useful in multi-interface devices, where routing
can be policy-based (e.g with output traffic classification rules based on
src address/device).

Signed-off-by: Luca Pesce <luca.pesce@vimar.com>
Signed-off-by: Pedro Aguilar <pedro.aguilar@vimar.com>
---
 corelib/channel_curl.c     | 12 ++++++++++++
 include/channel_curl.h     |  1 +
 suricatta/common.c         |  3 +++
 suricatta/server_hawkbit.c |  9 +++++++--
 4 files changed, 23 insertions(+), 2 deletions(-)

Comments

Stefano Babic Feb. 13, 2020, 10:31 a.m. UTC | #1
Hi Luca, Pedro,

On 13.02.20 09:03, Luca Pesce wrote:
> This patch adds the -f cmdline arg and the "interface" parameter to suricatta
> to optionally bind communication channel to a specific interface or IP address.
> To do so, a new config option is added to curl channel interface, which then
> exploits CURLOPT_INTERFACE option.
> Binding to an interface is useful in multi-interface devices, where routing
> can be policy-based (e.g with output traffic classification rules based on
> src address/device).
> 
> Signed-off-by: Luca Pesce <luca.pesce@vimar.com>
> Signed-off-by: Pedro Aguilar <pedro.aguilar@vimar.com>
> ---
>  corelib/channel_curl.c     | 12 ++++++++++++
>  include/channel_curl.h     |  1 +
>  suricatta/common.c         |  3 +++
>  suricatta/server_hawkbit.c |  9 +++++++--
>  4 files changed, 23 insertions(+), 2 deletions(-)
> 
> diff --git a/corelib/channel_curl.c b/corelib/channel_curl.c
> index 9062a73..c00e994 100644
> --- a/corelib/channel_curl.c
> +++ b/corelib/channel_curl.c
> @@ -600,6 +600,18 @@ channel_op_res_t channel_set_options(channel_t *this,
>  		}
>  	}
> 
> +	/*
> +	 * If requested, use a specific interface/IP address
> +	 */
> +	if (channel_data->iface != NULL) {
> +		if (curl_easy_setopt(channel_curl->handle,
> +		    CURLOPT_INTERFACE,
> +		    channel_data->iface) != CURLE_OK) {
> +			result = CHANNEL_EINIT;
> +			goto cleanup;
> +		}
> +	}
> +
>  	switch (method) {
>  	case CHANNEL_GET:
>  		if (curl_easy_setopt(channel_curl->handle, CURLOPT_CUSTOMREQUEST,
> diff --git a/include/channel_curl.h b/include/channel_curl.h
> index 0e499c6..2904712 100644
> --- a/include/channel_curl.h
> +++ b/include/channel_curl.h
> @@ -37,6 +37,7 @@ typedef struct {
>  	char *url;
>  	char *auth;
>  	char *request_body;
> +	char *iface;
>  #ifdef CONFIG_JSON
>  	json_object *json_reply;
>  #endif
> diff --git a/suricatta/common.c b/suricatta/common.c
> index 51b7be8..bf2bcd2 100644
> --- a/suricatta/common.c
> +++ b/suricatta/common.c
> @@ -42,6 +42,9 @@ void suricatta_channel_settings(void *elem, channel_data_t *chan)
>  	GET_FIELD_STRING_RESET(LIBCFG_PARSER, elem, "proxy", tmp);
>  	if (strlen(tmp))
>  		SETSTRING(chan->proxy, tmp);
> +	GET_FIELD_STRING_RESET(LIBCFG_PARSER, elem, "interface", tmp);
> +	if (strlen(tmp))
> +		SETSTRING(chan->iface, tmp);
>  }
>  
>  server_op_res_t map_channel_retcode(channel_op_res_t response)
> diff --git a/suricatta/server_hawkbit.c b/suricatta/server_hawkbit.c
> index 55aa419..b6d7f1b 100644
> --- a/suricatta/server_hawkbit.c
> +++ b/suricatta/server_hawkbit.c
> @@ -46,6 +46,7 @@ static struct option long_options[] = {
>      {"proxy", optional_argument, NULL, 'y'},
>      {"targettoken", required_argument, NULL, 'k'},
>      {"gatewaytoken", required_argument, NULL, 'g'},
> +    {"interface", required_argument, NULL, 'f'},
>      {NULL, 0, NULL, 0}};
>  
>  static unsigned short mandatory_argument_count = 0;
> @@ -1444,7 +1445,8 @@ void server_print_help(void)
>  	    "\t  -y, --proxy         Use proxy. Either give proxy URL, else "
>  	    "{http,all}_proxy env is tried.\n"
>  	    "\t  -k, --targettoken   Set target token.\n"
> -	    "\t  -g, --gatewaytoken  Set gateway token.\n",
> +	    "\t  -g, --gatewaytoken  Set gateway token.\n"
> +	    "\t  -f, --interface     Set the network interface to connect to Hawkbit.\n",
>  	    CHANNEL_DEFAULT_POLLING_INTERVAL, CHANNEL_DEFAULT_RESUME_TRIES,
>  	    CHANNEL_DEFAULT_RESUME_DELAY);
>  }
> @@ -1519,7 +1521,7 @@ server_op_res_t server_start(char *fname, int argc, char *argv[])
>  
>  	/* reset to optind=1 to parse suricatta's argument vector */
>  	optind = 1;
> -	while ((choice = getopt_long(argc, argv, "t:i:c:u:p:xr:y::w:k:g:",
> +	while ((choice = getopt_long(argc, argv, "t:i:c:u:p:xr:y::w:k:g:f:",
>  				     long_options, NULL)) != -1) {
>  		switch (choice) {
>  		case 't':
> @@ -1595,6 +1597,9 @@ server_op_res_t server_start(char *fname, int argc, char *argv[])
>  			channel_data_defaults.retry_sleep =
>  			    (unsigned int)strtoul(optarg, NULL, 10);
>  			break;
> +		case 'f':
> +			SETSTRING(channel_data_defaults.iface, optarg);
> +			break;
>  		case '?':
>  		default:
>  			return SERVER_EINIT;
> 

Patch is fine. However, the new parameter is not documented, please add
it, thanks !

Best regards,
Stefano Babic
Pesce Luca Feb. 13, 2020, 11:19 a.m. UTC | #2
Hi Stefano,
  I sent a subsequent patch to add the new parameter to the example configuration file, but for some reason it created a new thread - for sure a mistake on my side (reply-to was not right, I guess), sorry about this.
The new patch is this one:
http://patchwork.ozlabs.org/patch/1237422/

Regards,
Luca
Stefano Babic Feb. 13, 2020, 11:20 a.m. UTC | #3
On 13.02.20 12:19, Pesce Luca wrote:
> Hi Stefano,
>   I sent a subsequent patch to add the new parameter to the example configuration file, but for some reason it created a new thread - for sure a mistake on my side (reply-to was not right, I guess), sorry about this.
> The new patch is this one:
> http://patchwork.ozlabs.org/patch/1237422/

It does not matter.

It is still missing the documentation in doc/swupdate.rst to explain the
command line parameter (even if I see that this part should be rework in
some way).

Best regards,
Stefano

> 
> Regards,
> Luca
> 
> ________________________________________
> Da: Stefano Babic <sbabic@denx.de>
> Inviato: giovedì 13 febbraio 2020 11:31
> A: Pesce Luca; swupdate@googlegroups.com
> Cc: Aguilar Pedro
> Oggetto: Re: [swupdate] [PATCH] suricatta: added option to bind to interface/IP address.
> 
> Hi Luca, Pedro,
> 
> On 13.02.20 09:03, Luca Pesce wrote:
>> This patch adds the -f cmdline arg and the "interface" parameter to suricatta
>> to optionally bind communication channel to a specific interface or IP address.
>> To do so, a new config option is added to curl channel interface, which then
>> exploits CURLOPT_INTERFACE option.
>> Binding to an interface is useful in multi-interface devices, where routing
>> can be policy-based (e.g with output traffic classification rules based on
>> src address/device).
>>
>> Signed-off-by: Luca Pesce <luca.pesce@vimar.com>
>> Signed-off-by: Pedro Aguilar <pedro.aguilar@vimar.com>
>> ---
>>  corelib/channel_curl.c     | 12 ++++++++++++
>>  include/channel_curl.h     |  1 +
>>  suricatta/common.c         |  3 +++
>>  suricatta/server_hawkbit.c |  9 +++++++--
>>  4 files changed, 23 insertions(+), 2 deletions(-)
>>
>> diff --git a/corelib/channel_curl.c b/corelib/channel_curl.c
>> index 9062a73..c00e994 100644
>> --- a/corelib/channel_curl.c
>> +++ b/corelib/channel_curl.c
>> @@ -600,6 +600,18 @@ channel_op_res_t channel_set_options(channel_t *this,
>>               }
>>       }
>>
>> +     /*
>> +      * If requested, use a specific interface/IP address
>> +      */
>> +     if (channel_data->iface != NULL) {
>> +             if (curl_easy_setopt(channel_curl->handle,
>> +                 CURLOPT_INTERFACE,
>> +                 channel_data->iface) != CURLE_OK) {
>> +                     result = CHANNEL_EINIT;
>> +                     goto cleanup;
>> +             }
>> +     }
>> +
>>       switch (method) {
>>       case CHANNEL_GET:
>>               if (curl_easy_setopt(channel_curl->handle, CURLOPT_CUSTOMREQUEST,
>> diff --git a/include/channel_curl.h b/include/channel_curl.h
>> index 0e499c6..2904712 100644
>> --- a/include/channel_curl.h
>> +++ b/include/channel_curl.h
>> @@ -37,6 +37,7 @@ typedef struct {
>>       char *url;
>>       char *auth;
>>       char *request_body;
>> +     char *iface;
>>  #ifdef CONFIG_JSON
>>       json_object *json_reply;
>>  #endif
>> diff --git a/suricatta/common.c b/suricatta/common.c
>> index 51b7be8..bf2bcd2 100644
>> --- a/suricatta/common.c
>> +++ b/suricatta/common.c
>> @@ -42,6 +42,9 @@ void suricatta_channel_settings(void *elem, channel_data_t *chan)
>>       GET_FIELD_STRING_RESET(LIBCFG_PARSER, elem, "proxy", tmp);
>>       if (strlen(tmp))
>>               SETSTRING(chan->proxy, tmp);
>> +     GET_FIELD_STRING_RESET(LIBCFG_PARSER, elem, "interface", tmp);
>> +     if (strlen(tmp))
>> +             SETSTRING(chan->iface, tmp);
>>  }
>>
>>  server_op_res_t map_channel_retcode(channel_op_res_t response)
>> diff --git a/suricatta/server_hawkbit.c b/suricatta/server_hawkbit.c
>> index 55aa419..b6d7f1b 100644
>> --- a/suricatta/server_hawkbit.c
>> +++ b/suricatta/server_hawkbit.c
>> @@ -46,6 +46,7 @@ static struct option long_options[] = {
>>      {"proxy", optional_argument, NULL, 'y'},
>>      {"targettoken", required_argument, NULL, 'k'},
>>      {"gatewaytoken", required_argument, NULL, 'g'},
>> +    {"interface", required_argument, NULL, 'f'},
>>      {NULL, 0, NULL, 0}};
>>
>>  static unsigned short mandatory_argument_count = 0;
>> @@ -1444,7 +1445,8 @@ void server_print_help(void)
>>           "\t  -y, --proxy         Use proxy. Either give proxy URL, else "
>>           "{http,all}_proxy env is tried.\n"
>>           "\t  -k, --targettoken   Set target token.\n"
>> -         "\t  -g, --gatewaytoken  Set gateway token.\n",
>> +         "\t  -g, --gatewaytoken  Set gateway token.\n"
>> +         "\t  -f, --interface     Set the network interface to connect to Hawkbit.\n",
>>           CHANNEL_DEFAULT_POLLING_INTERVAL, CHANNEL_DEFAULT_RESUME_TRIES,
>>           CHANNEL_DEFAULT_RESUME_DELAY);
>>  }
>> @@ -1519,7 +1521,7 @@ server_op_res_t server_start(char *fname, int argc, char *argv[])
>>
>>       /* reset to optind=1 to parse suricatta's argument vector */
>>       optind = 1;
>> -     while ((choice = getopt_long(argc, argv, "t:i:c:u:p:xr:y::w:k:g:",
>> +     while ((choice = getopt_long(argc, argv, "t:i:c:u:p:xr:y::w:k:g:f:",
>>                                    long_options, NULL)) != -1) {
>>               switch (choice) {
>>               case 't':
>> @@ -1595,6 +1597,9 @@ server_op_res_t server_start(char *fname, int argc, char *argv[])
>>                       channel_data_defaults.retry_sleep =
>>                           (unsigned int)strtoul(optarg, NULL, 10);
>>                       break;
>> +             case 'f':
>> +                     SETSTRING(channel_data_defaults.iface, optarg);
>> +                     break;
>>               case '?':
>>               default:
>>                       return SERVER_EINIT;
>>
> 
> Patch is fine. However, the new parameter is not documented, please add
> it, thanks !
> 
> Best regards,
> Stefano Babic
> 
> --
> =====================================================================
> DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
> Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic@denx.de
> =====================================================================
>
Pesce Luca Feb. 13, 2020, 12:17 p.m. UTC | #4
Hi Stefano,
   I took a look at swupdate.rst, but I could not see a section for suricatta-specific cmdline args (the new -f of the proposed patch is a suricatta arg).
There is just the table for swupdate main application arguments, with the -u line referring to suricatta doc page, which in turn has no cmdline options table... for example, also the --confirm arg is missing...
The only place I found with a complete list was the example configuration file...

Regards,
Luca
Stefano Babic Feb. 16, 2020, 8:05 p.m. UTC | #5
Hi Luca,

On 13/02/20 13:17, Pesce Luca wrote:
> Hi Stefano,
>    I took a look at swupdate.rst, but I could not see a section for suricatta-specific cmdline args (the new -f of the proposed patch is a suricatta arg).
> There is just the table for swupdate main application arguments, with the -u line referring to suricatta doc page, which in turn has no cmdline options table... for example, also the --confirm arg is missing...
> The only place I found with a complete list was the example configuration file...
> 

Patch does not apply - could you rebase on TOT and resubmit ? - Thanks !

Best regards,
Stefano Babic

> Regards,
> Luca
> 
> ________________________________________
> Da: Stefano Babic <sbabic@denx.de>
> Inviato: giovedì 13 febbraio 2020 12:20
> A: Pesce Luca; Stefano Babic; swupdate@googlegroups.com
> Cc: Aguilar Pedro
> Oggetto: Re: R: [swupdate] [PATCH] suricatta: added option to bind to interface/IP address.
> 
> On 13.02.20 12:19, Pesce Luca wrote:
>> Hi Stefano,
>>   I sent a subsequent patch to add the new parameter to the example configuration file, but for some reason it created a new thread - for sure a mistake on my side (reply-to was not right, I guess), sorry about this.
>> The new patch is this one:
>> https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fpatchwork.ozlabs.org%2Fpatch%2F1237422%2F&amp;data=01%7C01%7CLuca.Pesce%40vimar.com%7C734f4cceceda42e5fa5808d7b076ce3a%7Ca1f008bcd59b4c668f8760fd9af15c7f%7C1&amp;sdata=0KQ80iHRr8jqRU%2FEhDTJYLYAvcDh7DpooAY2f0Oa0ZU%3D&amp;reserved=0
> 
> It does not matter.
> 
> It is still missing the documentation in doc/swupdate.rst to explain the
> command line parameter (even if I see that this part should be rework in
> some way).
> 
> Best regards,
> Stefano
> 
>>
>> Regards,
>> Luca
>>
>> ________________________________________
>> Da: Stefano Babic <sbabic@denx.de>
>> Inviato: giovedì 13 febbraio 2020 11:31
>> A: Pesce Luca; swupdate@googlegroups.com
>> Cc: Aguilar Pedro
>> Oggetto: Re: [swupdate] [PATCH] suricatta: added option to bind to interface/IP address.
>>
>> Hi Luca, Pedro,
>>
>> On 13.02.20 09:03, Luca Pesce wrote:
>>> This patch adds the -f cmdline arg and the "interface" parameter to suricatta
>>> to optionally bind communication channel to a specific interface or IP address.
>>> To do so, a new config option is added to curl channel interface, which then
>>> exploits CURLOPT_INTERFACE option.
>>> Binding to an interface is useful in multi-interface devices, where routing
>>> can be policy-based (e.g with output traffic classification rules based on
>>> src address/device).
>>>
>>> Signed-off-by: Luca Pesce <luca.pesce@vimar.com>
>>> Signed-off-by: Pedro Aguilar <pedro.aguilar@vimar.com>
>>> ---
>>>  corelib/channel_curl.c     | 12 ++++++++++++
>>>  include/channel_curl.h     |  1 +
>>>  suricatta/common.c         |  3 +++
>>>  suricatta/server_hawkbit.c |  9 +++++++--
>>>  4 files changed, 23 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/corelib/channel_curl.c b/corelib/channel_curl.c
>>> index 9062a73..c00e994 100644
>>> --- a/corelib/channel_curl.c
>>> +++ b/corelib/channel_curl.c
>>> @@ -600,6 +600,18 @@ channel_op_res_t channel_set_options(channel_t *this,
>>>               }
>>>       }
>>>
>>> +     /*
>>> +      * If requested, use a specific interface/IP address
>>> +      */
>>> +     if (channel_data->iface != NULL) {
>>> +             if (curl_easy_setopt(channel_curl->handle,
>>> +                 CURLOPT_INTERFACE,
>>> +                 channel_data->iface) != CURLE_OK) {
>>> +                     result = CHANNEL_EINIT;
>>> +                     goto cleanup;
>>> +             }
>>> +     }
>>> +
>>>       switch (method) {
>>>       case CHANNEL_GET:
>>>               if (curl_easy_setopt(channel_curl->handle, CURLOPT_CUSTOMREQUEST,
>>> diff --git a/include/channel_curl.h b/include/channel_curl.h
>>> index 0e499c6..2904712 100644
>>> --- a/include/channel_curl.h
>>> +++ b/include/channel_curl.h
>>> @@ -37,6 +37,7 @@ typedef struct {
>>>       char *url;
>>>       char *auth;
>>>       char *request_body;
>>> +     char *iface;
>>>  #ifdef CONFIG_JSON
>>>       json_object *json_reply;
>>>  #endif
>>> diff --git a/suricatta/common.c b/suricatta/common.c
>>> index 51b7be8..bf2bcd2 100644
>>> --- a/suricatta/common.c
>>> +++ b/suricatta/common.c
>>> @@ -42,6 +42,9 @@ void suricatta_channel_settings(void *elem, channel_data_t *chan)
>>>       GET_FIELD_STRING_RESET(LIBCFG_PARSER, elem, "proxy", tmp);
>>>       if (strlen(tmp))
>>>               SETSTRING(chan->proxy, tmp);
>>> +     GET_FIELD_STRING_RESET(LIBCFG_PARSER, elem, "interface", tmp);
>>> +     if (strlen(tmp))
>>> +             SETSTRING(chan->iface, tmp);
>>>  }
>>>
>>>  server_op_res_t map_channel_retcode(channel_op_res_t response)
>>> diff --git a/suricatta/server_hawkbit.c b/suricatta/server_hawkbit.c
>>> index 55aa419..b6d7f1b 100644
>>> --- a/suricatta/server_hawkbit.c
>>> +++ b/suricatta/server_hawkbit.c
>>> @@ -46,6 +46,7 @@ static struct option long_options[] = {
>>>      {"proxy", optional_argument, NULL, 'y'},
>>>      {"targettoken", required_argument, NULL, 'k'},
>>>      {"gatewaytoken", required_argument, NULL, 'g'},
>>> +    {"interface", required_argument, NULL, 'f'},
>>>      {NULL, 0, NULL, 0}};
>>>
>>>  static unsigned short mandatory_argument_count = 0;
>>> @@ -1444,7 +1445,8 @@ void server_print_help(void)
>>>           "\t  -y, --proxy         Use proxy. Either give proxy URL, else "
>>>           "{http,all}_proxy env is tried.\n"
>>>           "\t  -k, --targettoken   Set target token.\n"
>>> -         "\t  -g, --gatewaytoken  Set gateway token.\n",
>>> +         "\t  -g, --gatewaytoken  Set gateway token.\n"
>>> +         "\t  -f, --interface     Set the network interface to connect to Hawkbit.\n",
>>>           CHANNEL_DEFAULT_POLLING_INTERVAL, CHANNEL_DEFAULT_RESUME_TRIES,
>>>           CHANNEL_DEFAULT_RESUME_DELAY);
>>>  }
>>> @@ -1519,7 +1521,7 @@ server_op_res_t server_start(char *fname, int argc, char *argv[])
>>>
>>>       /* reset to optind=1 to parse suricatta's argument vector */
>>>       optind = 1;
>>> -     while ((choice = getopt_long(argc, argv, "t:i:c:u:p:xr:y::w:k:g:",
>>> +     while ((choice = getopt_long(argc, argv, "t:i:c:u:p:xr:y::w:k:g:f:",
>>>                                    long_options, NULL)) != -1) {
>>>               switch (choice) {
>>>               case 't':
>>> @@ -1595,6 +1597,9 @@ server_op_res_t server_start(char *fname, int argc, char *argv[])
>>>                       channel_data_defaults.retry_sleep =
>>>                           (unsigned int)strtoul(optarg, NULL, 10);
>>>                       break;
>>> +             case 'f':
>>> +                     SETSTRING(channel_data_defaults.iface, optarg);
>>> +                     break;
>>>               case '?':
>>>               default:
>>>                       return SERVER_EINIT;
>>>
>>
>> Patch is fine. However, the new parameter is not documented, please add
>> it, thanks !
>>
>> Best regards,
>> Stefano Babic
>>
>> --
>> =====================================================================
>> DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
>> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
>> Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic@denx.de
>> =====================================================================
>>
> 
> 
> --
> =====================================================================
> DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
> Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic@denx.de
> =====================================================================
>

Patch
diff mbox series

diff --git a/corelib/channel_curl.c b/corelib/channel_curl.c
index 9062a73..c00e994 100644
--- a/corelib/channel_curl.c
+++ b/corelib/channel_curl.c
@@ -600,6 +600,18 @@  channel_op_res_t channel_set_options(channel_t *this,
 		}
 	}

+	/*
+	 * If requested, use a specific interface/IP address
+	 */
+	if (channel_data->iface != NULL) {
+		if (curl_easy_setopt(channel_curl->handle,
+		    CURLOPT_INTERFACE,
+		    channel_data->iface) != CURLE_OK) {
+			result = CHANNEL_EINIT;
+			goto cleanup;
+		}
+	}
+
 	switch (method) {
 	case CHANNEL_GET:
 		if (curl_easy_setopt(channel_curl->handle, CURLOPT_CUSTOMREQUEST,
diff --git a/include/channel_curl.h b/include/channel_curl.h
index 0e499c6..2904712 100644
--- a/include/channel_curl.h
+++ b/include/channel_curl.h
@@ -37,6 +37,7 @@  typedef struct {
 	char *url;
 	char *auth;
 	char *request_body;
+	char *iface;
 #ifdef CONFIG_JSON
 	json_object *json_reply;
 #endif
diff --git a/suricatta/common.c b/suricatta/common.c
index 51b7be8..bf2bcd2 100644
--- a/suricatta/common.c
+++ b/suricatta/common.c
@@ -42,6 +42,9 @@  void suricatta_channel_settings(void *elem, channel_data_t *chan)
 	GET_FIELD_STRING_RESET(LIBCFG_PARSER, elem, "proxy", tmp);
 	if (strlen(tmp))
 		SETSTRING(chan->proxy, tmp);
+	GET_FIELD_STRING_RESET(LIBCFG_PARSER, elem, "interface", tmp);
+	if (strlen(tmp))
+		SETSTRING(chan->iface, tmp);
 }
 
 server_op_res_t map_channel_retcode(channel_op_res_t response)
diff --git a/suricatta/server_hawkbit.c b/suricatta/server_hawkbit.c
index 55aa419..b6d7f1b 100644
--- a/suricatta/server_hawkbit.c
+++ b/suricatta/server_hawkbit.c
@@ -46,6 +46,7 @@  static struct option long_options[] = {
     {"proxy", optional_argument, NULL, 'y'},
     {"targettoken", required_argument, NULL, 'k'},
     {"gatewaytoken", required_argument, NULL, 'g'},
+    {"interface", required_argument, NULL, 'f'},
     {NULL, 0, NULL, 0}};
 
 static unsigned short mandatory_argument_count = 0;
@@ -1444,7 +1445,8 @@  void server_print_help(void)
 	    "\t  -y, --proxy         Use proxy. Either give proxy URL, else "
 	    "{http,all}_proxy env is tried.\n"
 	    "\t  -k, --targettoken   Set target token.\n"
-	    "\t  -g, --gatewaytoken  Set gateway token.\n",
+	    "\t  -g, --gatewaytoken  Set gateway token.\n"
+	    "\t  -f, --interface     Set the network interface to connect to Hawkbit.\n",
 	    CHANNEL_DEFAULT_POLLING_INTERVAL, CHANNEL_DEFAULT_RESUME_TRIES,
 	    CHANNEL_DEFAULT_RESUME_DELAY);
 }
@@ -1519,7 +1521,7 @@  server_op_res_t server_start(char *fname, int argc, char *argv[])
 
 	/* reset to optind=1 to parse suricatta's argument vector */
 	optind = 1;
-	while ((choice = getopt_long(argc, argv, "t:i:c:u:p:xr:y::w:k:g:",
+	while ((choice = getopt_long(argc, argv, "t:i:c:u:p:xr:y::w:k:g:f:",
 				     long_options, NULL)) != -1) {
 		switch (choice) {
 		case 't':
@@ -1595,6 +1597,9 @@  server_op_res_t server_start(char *fname, int argc, char *argv[])
 			channel_data_defaults.retry_sleep =
 			    (unsigned int)strtoul(optarg, NULL, 10);
 			break;
+		case 'f':
+			SETSTRING(channel_data_defaults.iface, optarg);
+			break;
 		case '?':
 		default:
 			return SERVER_EINIT;