rpki-client http client and bind to address

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

rpki-client http client and bind to address

Claudio Jeker
When -b is used rpki-client should bind to that address for outgoing
connections. The http code does that but only warns if a bind call fails
but try the connect none the less. This is different from other network
tools (nc, ftp, telnet). So change this to a real error.

--
:wq Claudio

Index: http.c
===================================================================
RCS file: /cvs/src/usr.sbin/rpki-client/http.c,v
retrieving revision 1.18
diff -u -p -r1.18 http.c
--- http.c 6 Apr 2021 12:35:24 -0000 1.18
+++ http.c 7 Apr 2021 10:50:43 -0000
@@ -493,8 +493,14 @@ http_connect(struct http_connection *con
 
  if (http_bindaddr.ss_family == res->ai_family) {
  if (bind(conn->fd, (struct sockaddr *)&http_bindaddr,
-    res->ai_addrlen) == -1)
- warn("%s: bind", http_info(conn->url));
+    res->ai_addrlen) == -1) {
+ save_errno = errno;
+ close(conn->fd);
+ conn->fd = -1;
+ errno = save_errno;
+ cause = "bind";
+ continue;
+ }
  }
 
  if (connect(conn->fd, res->ai_addr, res->ai_addrlen) == -1) {

Reply | Threaded
Open this post in threaded view
|

Re: rpki-client http client and bind to address

Theo Buehler-3
On Wed, Apr 07, 2021 at 12:55:50PM +0200, Claudio Jeker wrote:
> When -b is used rpki-client should bind to that address for outgoing
> connections. The http code does that but only warns if a bind call fails
> but try the connect none the less. This is different from other network
> tools (nc, ftp, telnet). So change this to a real error.

ok tb

>
> --
> :wq Claudio
>
> Index: http.c
> ===================================================================
> RCS file: /cvs/src/usr.sbin/rpki-client/http.c,v
> retrieving revision 1.18
> diff -u -p -r1.18 http.c
> --- http.c 6 Apr 2021 12:35:24 -0000 1.18
> +++ http.c 7 Apr 2021 10:50:43 -0000
> @@ -493,8 +493,14 @@ http_connect(struct http_connection *con
>  
>   if (http_bindaddr.ss_family == res->ai_family) {
>   if (bind(conn->fd, (struct sockaddr *)&http_bindaddr,
> -    res->ai_addrlen) == -1)
> - warn("%s: bind", http_info(conn->url));
> +    res->ai_addrlen) == -1) {
> + save_errno = errno;
> + close(conn->fd);
> + conn->fd = -1;
> + errno = save_errno;
> + cause = "bind";
> + continue;
> + }
>   }
>  
>   if (connect(conn->fd, res->ai_addr, res->ai_addrlen) == -1) {
>