ip nexthop: use the request size as the limit when adding encap
ipnh_modify() passes a hardcoded 1024 as the size limit to addraw_l()
when it adds the encap attribute, and ignores the return value. Every
other attribute in this function is bounded by sizeof(req). If the encap
attribute does not fit, for example a seg6 encap with 59 segments,
addraw_l() prints "addraw_l ERROR: message exceeded bound of 1024" and
returns -1, but ip sends the request without the encap attribute and
exits with status 0. A nexthop without encap is then installed silently.
Use sizeof(req) as the limit, like the other attributes, and return an
error if addraw_l() fails instead of sending an incomplete request.
Fixes: 63df8e8543b0 ("Add support for nexthop objects")
Assisted-by: Claude:claude-sonnet-5-5
Signed-off-by: Fang Jiabao <kaquoin@163.com>
1 file changed