On 12/11/14 at 05:21pm, Minfei Huang wrote:
On 12/11/14 at 03:07pm, Baoquan He wrote:
> On 12/05/14 at 04:24pm, Minfei Huang wrote:
>
> > +# in the same subnet region, following is the route format
>
> I like writing it like this:
>
> # for routes to the same subnet, following is the foramt:
> # xxxxxxxxx
>
Ok, I will add it in next re-send patch.
> > +#
> > +# _route='2001:11::11f from :: dev eth1 src 2001:11::120 metric 0
> > +# cache'
> > +# in the different subnet region, following is the route format
> > +# _route='2001:10::120 from :: via 2001:11::11f dev eth1 src 2001:11::120
metric 0
> > +# cache'
> > +#
> > + _netdev=$(kdump_setup_ifname $_netdev)
> > + if `echo $_route | grep -q "via"`; then
> > + # route going to a different subnet via a router
> > + _nexthop=`echo $_route | awk '{print $5}'`
> > + echo "rd.route=[$_target]:[$_nexthop]:$_netdev" >>
${initdir}/etc/cmdline.d/45route-static.conf
> > + else
> > + echo "rd.route=[$_target]::$_netdev" >>
${initdir}/etc/cmdline.d/45route-static.conf
> > + fi
> > + else
> > + _route=`/sbin/ip route get to $_target 2>&1`
> > #
> > # in the same subnet region, following is the route format
> > # _route='192.168.200.137 dev eth1 src 192.168.200.129
> > @@ -205,13 +235,14 @@ get_routes() {
> > # _route='192.168.201.215 via 192.168.200.137 dev eth1 src
192.168.200.129
> > # cache '
>
> I would like to put these description as function comment above function
> definition, adding blocks of comment in the middle looks messy.
>
The position of note is better in my opinion. We can known what the
scirpt does according the above note. It is clearer.
Well, no matter how long the code comment which is above function
definition, it doesn't matter reading code. Putting too many comments in
a so short function, don't you think it's very ugly? Anyway it's a not
complicated function, and function name can indicate what it is doing, I
don't think you need worry it will become not clear if put it above
function definition. Just a note, people who interested in that can read
it, or just ignore it and run into codes. But put it into codes, you
have to avoid it.