From: Hangbin Liu <hidden> Date: 2023-09-13 09:29:07
Hi,
After a long busy period. I got time to check how to update the bridge doc.
Here is the previous discussion we made[1].
In this update. I plan to convert all the bridge description/comments to
the kernel headers. And add sphinx identifiers in the doc to show them
directly. At the same time, I wrote a script to convert the description
in kernel header file to iproute2 man doc. With this, there is no need
to maintain the doc in 2 places.
For the script. I use python docutils to read the rst comments. When dump
the man page. I do it manually to match the current ip link man page style.
I tried rst2man, but the generated man doc will break the current style.
If you have any other better way, please tell me.
[1] https://lore.kernel.org/netdev/5ddac447-c268-e559-a8dc-08ae3d124352@blackwall.org/
Hangbin Liu (1):
Doc: update bridge doc
Documentation/networking/bridge.rst | 85 ++++++++++--
include/uapi/linux/if_bridge.h | 24 ++++
include/uapi/linux/if_link.h | 194 ++++++++++++++++++++++++++++
3 files changed, 293 insertions(+), 10 deletions(-)
--
2.41.0
From: Hangbin Liu <hidden> Date: 2023-09-13 09:29:10
This is an example of bridge doc update. In this example I use the
sphinx identifier to insert the structure description in the doc.
I plan to copy all the iproute2 bridge related man docs first.
Please tell me if other doc I need to add.
Signed-off-by: Hangbin Liu <redacted>
---
Documentation/networking/bridge.rst | 85 ++++++++++--
include/uapi/linux/if_bridge.h | 24 ++++
include/uapi/linux/if_link.h | 194 ++++++++++++++++++++++++++++
3 files changed, 293 insertions(+), 10 deletions(-)
@@ -4,18 +4,83 @@ Ethernet Bridging =================-In order to use the Ethernet bridging functionality, you'll need the-userspace tools.+Introduction+============-Documentation for Linux bridging is on:- https://wiki.linuxfoundation.org/networking/bridge+A bridge is a way to connect two Ethernet segments together in a protocol+independent way. Packets are forwarded based on Ethernet address, rather+than IP address (like a router). Since forwarding is done at Layer 2, all+protocols can go transparently through a bridge.-The bridge-utilities are maintained at:- git://git.kernel.org/pub/scm/linux/kernel/git/shemminger/bridge-utils.git+Bridge internals+================-Additionally, the iproute2 utilities can be used to configure-bridge devices.+..kernel-doc:: include/uapi/linux/if_bridge.h+:identifiers: __bridge_info-If you still have questions, don't hesitate to post to the mailing list -(more info https://lists.linux-foundation.org/mailman/listinfo/bridge).+..kernel-doc:: include/uapi/linux/if_bridge.h+:identifiers: __port_info++Bridge uAPI+===========++Bridge netlink attributes+-------------------------++..kernel-doc:: include/uapi/linux/if_link.h+:doc: The bridge emum defination++Bridge sysfs+------------++Most of them are same with netlink attributes. What about the read only+parameters like gc_timer, tcn_timer? Should we doc them?++STP+===++Multicast+=========++VLAN+====++Switchdev+=========++Netfilter+=========++FAQ+===++What does a bridge do?+----------------------++A bridge transparently relays traffic between multiple network interfaces.+In plain English this means that a bridge connects two or more physical+Ethernets together to form one bigger (logical) Ethernet.++Is it protocol independent?+---------------------------++Yes. The bridge knows nothing about protocols, it only sees Ethernet frames.+As such, the bridging functionality is protocol independent, and there should+be no trouble relaying IPX, NetBEUI, IP, IPv6, etc.++Contact Info+============++The code is currently maintained by Roopa Prabhu <roopa@nvidia.com> and+Nikolay Aleksandrov <razor@blackwall.org>. Bridge bugs and enhancements+are discussed on the linux-netdev mailing list netdev@vger.kernel.org and+bridge@lists.linux-foundation.org.++The list is open to anyone interested: http://vger.kernel.org/vger-lists.html#netdev++External Links+==============++The old Documentation for Linux bridging is on:+https://wiki.linuxfoundation.org/networking/bridge
From: Hangbin Liu <hidden> Date: 2023-09-13 09:29:13
This tool will generate the ip link bridge parameters and find related
attr description in if_link.h. And convert to the new man doc.
To use it. You need to run the script first before your patch. With this
we can update the man page to latest version. e.g.
./generate_bridge_man.py -i iproute2_dir -n net-next_dir
The script will generate a ip-link.8.out page. You can check if it's OK
to move to ip-link.8.in.
After adding new parameter. You need to re-run the script to generate the man
doc from net-next header file.
The script check the existing parameter. So if the attr in net-next has not
added to iproute2, it will not generate the man doc.
Signed-off-by: Hangbin Liu <redacted>
---
man/man8/ip-link.8.in | 2 +
tools/generate_bridge_man.py | 188 +++++++++++++++++++++++++++++++++++
2 files changed, 190 insertions(+)
create mode 100755 tools/generate_bridge_man.py
@@ -1611,6 +1611,7 @@ For a link of type the following additional arguments are supported: .BI "ip link add " DEVICE " type bridge "+.\" bridge man doc starts [ .BI ageing_time " AGEING_TIME " ] [
@@ -1887,6 +1888,7 @@ arptables hooks on the bridge. .in -8+.\" bridge man doc ends .TP MACsec Type Support
@@ -0,0 +1,188 @@+#!/usr/bin/env python3+# SPDX-License-Identifier: GPL-2.0-only++importre,sys,os+importargparse+fromdocutilsimportcore++man_bridge=""++defhandle_args():+parser=argparse.ArgumentParser(description="""Convert bridge header+commentstoiproute2mandoc.""")+parser.add_argument('-i','--iproute2-dir',required=True,+help='iproute code path')+parser.add_argument('-n','--net-dir',required=True,+help='net-next code path')+args=parser.parse_args()+returnargs++defwrite_man_doc(input_file,output_file):+try:+withopen(input_file,'r')asinfile,open(output_file,'w')asoutfile:+remove_flag=False+forlineininfile:+ifline.find("bridge man doc starts")!=-1:+remove_flag=True+outfile.write(line)+outfile.write(man_bridge+'\n')+elifremove_flagandline.find("bridge man doc ends")!=-1:+remove_flag=False+elifnotremove_flag:+outfile.write(line)+exceptExceptionase:+sys.exit(e)++defappend_man_line(line,end='\n'):+globalman_bridge+man_bridge=man_bridge+line+end++defrst2man(node):+ifnothasattr(node,'astext'):+return++ifnode.tagname=='bullet_list':+append_man_line('.in +8\n.sp')+ifnode.tagname=='list_item':+append_man_line('')+elifnode.tagname=='emphasis':+append_man_line('.I ',end='')+elifnode.tagname=='strong':+append_man_line('.B ',end='')++forchild_nodeinnode.children:+rst2man(child_node)++iflen(node.children)==0:+text=node.astext().strip()+append_man_line(text)++ifnode.tagname=='bullet_list':+append_man_line('.in -8')++defconvert2man(params):+first=True+forpinparams:+iffirst:+first=False+append_man_line('[')+else:+append_man_line(' [')+append_man_line('.BI '+p+' " '+params[p]['param']+' "')+append_man_line(']',end='')++append_man_line('\n\n.in +8\n.sp')++forpinparams:+if'alias'inparams[p]:+# TODO: fix the vlan_protocol output, e.g. {|}+append_man_line('\n.BR '+p+' " '+params[p]['alias']+' "')+else:+append_man_line('\n.BI '+p+' " '+params[p]['param']+' "')+# Add the '- ' at begining of each description+append_man_line('- ',end='')+if'doc'inparams[p]:+rst_nodes=core.publish_doctree(params[p]['doc'])+rst2man(rst_nodes)++defstrip_doc_line(line,param):+# Remove the first " * "+line=line[5:-1]+# replace attr with param, e.g. IFLA_BR_STP_STATE -> STP_STATE+line=line.replace(param['attr'],param['param'])+returnline++defget_attr(line):+match=re.search(r'@(\w+):',line)+ifmatch:+returnmatch.group(1)+returnNone++# Deal some irregular namings+defparam2attr(param):+param=param.replace('count','cnt')+param=param.replace('interval','intvl')+param=param.replace('group_address','group_addr')+returnparam.upper()++defget_bridge_doc(bridge_header,params):+find_attr=False+p=None+try:+withopen(bridge_header,'r')asf:+line=f.readline()+# Find the start of the doc+whileline.find("DOC: The bridge emum defination")==-1:+ifnotline:+print("Unable to find bridge DOC");+returnNone+line=f.readline()+# Till the end of the doc+whileline.find("*/")==-1:+line=f.readline()+# Start of a parameter+ifline.find(' * @')==0:+find_attr=False+forpinparams:+ifline.find(param2attr(p)+':')!=-1:+attr=get_attr(line)+ifattrisnotNone:+params[p]['attr']=attr+find_attr=True+break+eliffind_attrandp:+if'doc'inparams[p]:+params[p]['doc']=params[p]['doc']+'\n'+strip_doc_line(line,params[p])+else:+params[p]['doc']=strip_doc_line(line,params[p])++exceptExceptionase:+sys.exit(e)++# replace multi text+defstrip_line(line):+returnline.replace(' ','').replace('"','').replace('\\n','').strip()++defget_bridge_parameter(bridge_file):+params={}+try:+withopen(bridge_file,'r')asf:+line=f.readline()+# Find the start of parameters+whileline.find("Usage: ... bridge")==-1:+line=f.readline()+# Till the end of the parameters+whileline.find("Where:")==-1:+line=f.readline()+parts=line.strip().split()+iflen(parts)>=4:+ifparts[1]=='[':+params[parts[2]]={}+params[parts[2]]['param']=parts[3]+# Till the end of usage function to get the alias+whileline.find(");")==-1:+parts=line.strip().replace('Where:','').split(':=')+alias=strip_line(parts[0])+forpinparams:+ifparams[p]['param']==alias:+params[p]['alias']=strip_line(parts[1])+line=f.readline()+exceptExceptionase:+sys.exit(e)++returnparams++defmain():+args=handle_args()+bridge_file=args.iproute2_dir.rstrip('/')+"/ip/iplink_bridge.c"+ip_link_in=args.iproute2_dir.rstrip('/')+"/man/man8/ip-link.8.in"+ip_link_out=args.iproute2_dir.rstrip('/')+"/man/man8/ip-link.8.out"+bridge_header=args.net_dir.rstrip('/')+'/include/uapi/linux/if_link.h'++bridge_params=get_bridge_parameter(bridge_file)+get_bridge_doc(bridge_header,bridge_params)+convert2man(bridge_params)+write_man_doc(ip_link_in,ip_link_out)++if__name__=='__main__':+main()
From: Stephen Hemminger <stephen@networkplumber.org> Date: 2023-09-13 11:22:30
On Wed, 13 Sep 2023 17:28:52 +0800
Hangbin Liu [off-list ref] wrote:
Hi,
After a long busy period. I got time to check how to update the
bridge doc. Here is the previous discussion we made[1].
In this update. I plan to convert all the bridge description/comments
to the kernel headers. And add sphinx identifiers in the doc to show
them directly. At the same time, I wrote a script to convert the
description in kernel header file to iproute2 man doc. With this,
there is no need to maintain the doc in 2 places.
For the script. I use python docutils to read the rst comments. When
dump the man page. I do it manually to match the current ip link man
page style. I tried rst2man, but the generated man doc will break the
current style. If you have any other better way, please tell me.
[1]
https://lore.kernel.org/netdev/5ddac447-c268-e559-a8dc-08ae3d124352@blackwall.org/
Hangbin Liu (1):
Doc: update bridge doc
Documentation/networking/bridge.rst | 85 ++++++++++--
include/uapi/linux/if_bridge.h | 24 ++++
include/uapi/linux/if_link.h | 194
++++++++++++++++++++++++++++ 3 files changed, 293 insertions(+), 10
deletions(-)
Not sure this is good idea.
- you are special casing bridge documentation and there is lots of
other parts of iproute2
- you are introducing a dependency on python in iproute2
- the kernel headers in iproute2 come from sanitized kernel headers. So
fixing the documentation would take longer.
What problem is this trying to solve?
From: Stephen Hemminger <stephen@networkplumber.org> Date: 2023-09-13 11:25:11
On Wed, 13 Sep 2023 17:28:52 +0800
Hangbin Liu [off-list ref] wrote:
Hi,
After a long busy period. I got time to check how to update the
bridge doc. Here is the previous discussion we made[1].
In this update. I plan to convert all the bridge description/comments
to the kernel headers. And add sphinx identifiers in the doc to show
them directly. At the same time, I wrote a script to convert the
description in kernel header file to iproute2 man doc. With this,
there is no need to maintain the doc in 2 places.
For the script. I use python docutils to read the rst comments. When
dump the man page. I do it manually to match the current ip link man
page style. I tried rst2man, but the generated man doc will break the
current style. If you have any other better way, please tell me.
[1]
https://lore.kernel.org/netdev/5ddac447-c268-e559-a8dc-08ae3d124352@blackwall.org/
Hangbin Liu (1):
Doc: update bridge doc
Documentation/networking/bridge.rst | 85 ++++++++++--
include/uapi/linux/if_bridge.h | 24 ++++
include/uapi/linux/if_link.h | 194
++++++++++++++++++++++++++++ 3 files changed, 293 insertions(+), 10
deletions(-)
Not sure this is good idea.
- you are special casing bridge documentation and there is lots of
other parts of iproute2
- you are introducing a dependency on python in iproute2
- the kernel headers in iproute2 come from sanitized kernel headers. So
fixing the documentation would take longer.
What problem is this trying to solve
From: Hangbin Liu <hidden> Date: 2023-09-14 03:06:16
On Wed, Sep 13, 2023 at 04:22:24AM -0700, Stephen Hemminger wrote:
On Wed, 13 Sep 2023 17:28:52 +0800
Hangbin Liu [off-list ref] wrote:
quoted
Hi,
After a long busy period. I got time to check how to update the
bridge doc. Here is the previous discussion we made[1].
In this update. I plan to convert all the bridge description/comments
to the kernel headers. And add sphinx identifiers in the doc to show
them directly. At the same time, I wrote a script to convert the
description in kernel header file to iproute2 man doc. With this,
there is no need to maintain the doc in 2 places.
For the script. I use python docutils to read the rst comments. When
dump the man page. I do it manually to match the current ip link man
page style. I tried rst2man, but the generated man doc will break the
current style. If you have any other better way, please tell me.
[1]
https://lore.kernel.org/netdev/5ddac447-c268-e559-a8dc-08ae3d124352@blackwall.org/
Hangbin Liu (1):
Doc: update bridge doc
Documentation/networking/bridge.rst | 85 ++++++++++--
include/uapi/linux/if_bridge.h | 24 ++++
include/uapi/linux/if_link.h | 194
++++++++++++++++++++++++++++ 3 files changed, 293 insertions(+), 10
deletions(-)
Not sure this is good idea.
- you are special casing bridge documentation and there is lots of
other parts of iproute2
Yes, the patch's purpose is to save the work for bridge doc(at present).
So only the bridge part of iproute2 man page will be updated. I added a
tag at the start/end of the bridge part. Other parts will not be touched.
- you are introducing a dependency on python in iproute2
There is no need to build it. I put it in the tools folder. Any one can
choose to use or not use it. So I don't think it count for dependency.
- the kernel headers in iproute2 come from sanitized kernel headers. So
fixing the documentation would take longer.
It doesn't matter. The python script only grab the attr description from
net-next and convert it to man doc. It doesn't care about the kernel
header in iproute2.
What problem is this trying to solve?
The bridge doc in kernel[1] is too old. There are a lot of details hide in
the kernel code and new developer is hard to catch up. So the kernel bridge
doc page need an update.
You could say the iproute2 bridge documentation is new and updated. We can
take it as the new bridge doc. But iprotue2 bridge doc only contains uAPI.
The kernel API doc is still needed.
On the other hand, the bridge developers already speed a lot effort on iproute2
bridge documentation. It would introduce more work and complex to maintain
the kernel and bridge doc at the same time.
So I suggest to only maintain the kernel doc. And convert the kernel part
directly to iproute2 man page. With this, we can maintain the doc in one
place and update them both on kernel and iproute2.
[1] https://www.kernel.org/doc/Documentation/networking/bridge.rst
Thanks
Hangbin
From: Hangbin Liu <hidden> Date: 2023-09-20 09:19:57
Hi Nikolay, Roopa,
Do you have any comments for this RFC?
Thanks
Hangbin
On Wed, Sep 13, 2023 at 05:28:52PM +0800, Hangbin Liu wrote:
Hi,
After a long busy period. I got time to check how to update the bridge doc.
Here is the previous discussion we made[1].
In this update. I plan to convert all the bridge description/comments to
the kernel headers. And add sphinx identifiers in the doc to show them
directly. At the same time, I wrote a script to convert the description
in kernel header file to iproute2 man doc. With this, there is no need
to maintain the doc in 2 places.
For the script. I use python docutils to read the rst comments. When dump
the man page. I do it manually to match the current ip link man page style.
I tried rst2man, but the generated man doc will break the current style.
If you have any other better way, please tell me.
[1] https://lore.kernel.org/netdev/5ddac447-c268-e559-a8dc-08ae3d124352@blackwall.org/
Hangbin Liu (1):
Doc: update bridge doc
Documentation/networking/bridge.rst | 85 ++++++++++--
include/uapi/linux/if_bridge.h | 24 ++++
include/uapi/linux/if_link.h | 194 ++++++++++++++++++++++++++++
3 files changed, 293 insertions(+), 10 deletions(-)
--
2.41.0
From: Nikolay Aleksandrov <razor@blackwall.org> Date: 2023-09-20 10:38:48
On 9/20/23 12:19, Hangbin Liu wrote:
Hi Nikolay, Roopa,
Do you have any comments for this RFC?
Thanks
Hangbin
On Wed, Sep 13, 2023 at 05:28:52PM +0800, Hangbin Liu wrote:
quoted
Hi,
After a long busy period. I got time to check how to update the bridge doc.
Here is the previous discussion we made[1].
In this update. I plan to convert all the bridge description/comments to
the kernel headers. And add sphinx identifiers in the doc to show them
directly. At the same time, I wrote a script to convert the description
in kernel header file to iproute2 man doc. With this, there is no need
to maintain the doc in 2 places.
For the script. I use python docutils to read the rst comments. When dump
the man page. I do it manually to match the current ip link man page style.
I tried rst2man, but the generated man doc will break the current style.
If you have any other better way, please tell me.
[1] https://lore.kernel.org/netdev/5ddac447-c268-e559-a8dc-08ae3d124352@blackwall.org/
Hangbin Liu (1):
Doc: update bridge doc
Documentation/networking/bridge.rst | 85 ++++++++++--
include/uapi/linux/if_bridge.h | 24 ++++
include/uapi/linux/if_link.h | 194 ++++++++++++++++++++++++++++
3 files changed, 293 insertions(+), 10 deletions(-)
--
2.41.0
Hi Hangbin,
I support all efforts to improve documentation, but I do share the same concerns that Stephen has already voiced. I don't think we should be generating the man page from the kernel docs, IMO it would be simpler
and easier for everyone to support both docs - one is for the user-space
iproute2 commands, the other could go into the kernel api details. All
attribute descriptions can still be added to headers, that would be very
valuable on its own. I prefer to have the freedom to change the docs format in any way, generating them from comments is kind of limiting.
The purpose of each document is different and it will be difficult
to combine them for a man page. It would be much easier for everyone
to add user-related command descriptions and examples in iproute2's documentation, and to add kernel-specific (or uapi) documentation to the
kernel doc. We can add references for each with a short description.
W.r.t the kernel doc topics covered, I think the list is a good start.
Thank you,
Nik
From: Hangbin Liu <hidden> Date: 2023-09-20 14:17:56
On Wed, Sep 20, 2023 at 01:38:44PM +0300, Nikolay Aleksandrov wrote:
quoted
On Wed, Sep 13, 2023 at 05:28:52PM +0800, Hangbin Liu wrote:
quoted
Hi,
After a long busy period. I got time to check how to update the bridge doc.
Here is the previous discussion we made[1].
In this update. I plan to convert all the bridge description/comments to
the kernel headers. And add sphinx identifiers in the doc to show them
directly. At the same time, I wrote a script to convert the description
in kernel header file to iproute2 man doc. With this, there is no need
to maintain the doc in 2 places.
For the script. I use python docutils to read the rst comments. When dump
the man page. I do it manually to match the current ip link man page style.
I tried rst2man, but the generated man doc will break the current style.
If you have any other better way, please tell me.
[1] https://lore.kernel.org/netdev/5ddac447-c268-e559-a8dc-08ae3d124352@blackwall.org/
Hi Hangbin,
I support all efforts to improve documentation, but I do share the same
concerns that Stephen has already voiced. I don't think we should be
generating the man page from the kernel docs, IMO it would be simpler
and easier for everyone to support both docs - one is for the user-space
iproute2 commands, the other could go into the kernel api details. All
attribute descriptions can still be added to headers, that would be very
valuable on its own. I prefer to have the freedom to change the docs format
in any way, generating them from comments is kind of limiting.
The purpose of each document is different and it will be difficult
to combine them for a man page. It would be much easier for everyone
to add user-related command descriptions and examples in iproute2's
documentation, and to add kernel-specific (or uapi) documentation to the
kernel doc. We can add references for each with a short description.
Hi Nikolay,
Thanks for the feedback. I agree that it's more reasonable to have
different docs for user-space and kernel api. As long as our bridge developers
satisfied to maintain these 2 docs at the same time, I'm totally OK to drop
this bloated convert tool.
W.r.t the kernel doc topics covered, I think the list is a good start.
Thanks, I will add more parts and re-post it next month.
Regards
Hangbin