Page MenuHomeFreeBSD

netgraph/ng_base: Allow larger BINARY2ASCII conversions
ClosedPublic

Authored by donner on Feb 26 2020, 12:48 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Oct 13, 3:14 AM
Unknown Object (File)
Thu, Oct 10, 7:23 PM
Unknown Object (File)
Thu, Oct 10, 7:23 PM
Unknown Object (File)
Thu, Oct 10, 7:23 PM
Unknown Object (File)
Thu, Oct 10, 7:22 PM
Unknown Object (File)
Thu, Oct 10, 7:22 PM
Unknown Object (File)
Thu, Oct 10, 8:15 AM
Unknown Object (File)
Oct 4 2024, 10:58 AM

Details

Summary

In PR187835 larger data couldn't be converted from BINARY to ASCII. The code does reach an hardcoded limit.

This patch allocated the necessary memory dynamically starting with a value which is sufficient for almost all normal cases.

Test Plan

Try the example in the bug report.
Retry after the patch.

I did add some debugging output to the code to validate the resizing is working correctly:

/usr/src/sys/netgraph/ng_base.c:2834: Double bufSize=1024
/usr/src/sys/netgraph/ng_base.c:2834: Double bufSize=2048
/usr/src/sys/netgraph/ng_base.c:2834: Double bufSize=4096
/usr/src/sys/netgraph/ng_base.c:2834: Double bufSize=8192
/usr/src/sys/netgraph/ng_base.c:2834: Double bufSize=16384
/usr/src/sys/netgraph/ng_base.c:2834: Double bufSize=32768
/usr/src/sys/netgraph/ng_base.c:2834: Double bufSize=65536
/usr/src/sys/netgraph/ng_base.c:2834: Double bufSize=131072
/usr/src/sys/netgraph/ng_base.c:2834: Double bufSize=262144
/usr/src/sys/netgraph/ng_base.c:2834: Double bufSize=524288
/usr/src/sys/netgraph/ng_base.c:2834: Double bufSize=1048576

Of course, to transmit the data via the ng_socket, the buffer sizes needs to be adjusted manually.

net.graph.recvspace: 204800
net.graph.maxdgram: 204800

To transmit arbitary large data, it's better to change the ng_socket interface (incl. libnetgraph), but that is out of scope of this issue here.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

afedorov added inline comments.
sys/netgraph/ng_base.c
2774

Do you really think that this is enough for almost all normal cases?
It seems that, only ng_bridge getstats return 80+ bytes per link.

sys/netgraph/ng_base.c
2774

I tried it with a network for A10NSP termination incl. a (netgraph emulated) testbed for 12 double-tagged 10G-lines holding 400 CPEs with two vlans each.

  Type name   Number of living nodes
  ---------   ----------------------
        car     429
      patch      12
        tag      13
   one2many      13
     bridge       2
        bpf       1
        tee      13
vlan_rotate       1
       vlan     545
     eiface     962
     socket       2

Each bridge node holds about 430 connections.

I had not a single buffer expansion request during setup and debugging. Only "msg bridge: gettable" needs a buffer size of >1M.

So I'm pretty sure, that the 1k limit is sufficient for most use cases. Let's conserve kernel memory.

sys/netgraph/ng_base.c
2774

40 CPEs. My fault.

That are the numbers for 400 CPE connecting per line for 12 lines and 900 active clients (dhclient ngethxxx).

  Type name   Number of living nodes
  ---------   ----------------------
        car     452
      patch      12
        tag      13
   one2many      13
     bridge       2
        bpf       1
        tee      13
vlan_rotate       1
       vlan    4865
     eiface    9600
     socket       2

The default 1k buffer is sufficient to setup and operate this network.

Updated to revision 358355.

This revision is now accepted and ready to land.Feb 8 2021, 1:11 PM