Willy,

Am 18.07.2018 um 14:30 schrieb Willy Tarreau:
>> I can rework the patch, if technical changes look good to you. There's a
>> ton of memcpy in there to not destroy the data structures needed for the
>> actual communication: make_proxy_line() now always operates on a copy of
>> `struct connection remote`.
> 
> I don't see why a copy could be needed, given that you should never have
> to modify anything in the source. Or maybe it's because it was more
> convenient to store the remapped addresses ? In this case I think that

Yes it is more convenient. In my current patch I just converted once in
connection.c and thus did not need to make any large logic changes in
make_proxy_line_v[12]: Keep the patch as small as possible.

> it's still cleaner to have two local struct sockaddr_storage that you
> can use for the operations. Another option, which I *thought* we had but
> am probably wrong on this, was to first check the source+destination

Yes, you do this, but you specifically check whether `src->ss_family ==
dst->ss_family`, not for every possible combination.

> address classes before deciding what to emit. (or maybe it's done in the
> PPv2 format) :
> 
>      if (src_is_v4 && dst_is_v4)
>           /* emit_v4(src, dst) */
>      else if (src_is_v6 && dst_is_v6)
>           /* emit_v6(src, dst) */
>      else if (src_is_v6 && dst_is_v4)
>           /* emit_v6(src, 4to6(dst)) */
>      else if (src_is_v4 && dst_is_v6)
>           /* emit_v6(4to6(src), dst) */
>      else
>           /* emit_unknown()*/
> 
> So in practice you always need only one temporary sockaddr_storage for
> a conversion.

Correct. Reason I did the copy (as mentioned above) is, that I did not
want to touch the actual logic.

> I'm personally fine with something roughly like this. Lukas, I'm interested
> in your opinion on this one, as I *think* it addresses the issues without
> introducing new ones. We could even think about backporting this.
> 

Best regards
Tim Düsterhus

Reply via email to