[Xorp-hackers] Xorp FEA crash

Ben Greear greearb at candelatech.com
Fri Jul 18 11:44:54 PDT 2008


Pavlin Radoslavov wrote:
> Ben Greear <greearb at candelatech.com> wrote:
> 
>> Ben Greear wrote:
>>> NOTE:  This is with my patches applied, so it could
>>> be my fault.  But, it looks like it could be a generic
>>> problem.
>> I added some more debugging.  It is hitting the assert at the end
>> of this code.  It looks like we should not be doing the CMSG_NXTHDR
>> if neither of the #ifdefs in this section are defined?
> 
> Ben,
> 
> The only reason I can think of that CMSG_NXTHDR() returns NULL is if
> the _sndmh.msg_controllen value is too small to accomodate all the
> options.
> For sending purpose, the _sndmh.msg_controllen value is set to
> "ctllen" which is precomputed on-the-fly before the ancillary data
> is setup.
> If the problem is indeed a small _sndmh.msg_controllen, then
> "ctllen" wasn't calculated properly, which is a bug in that part of
> the code.
> 
> Could you add some debug statements to print the value of
> _sndmh.msg_controllen and the calculation of "ctllen".
> 
> Also, it will be helpful if you can try the same setup with vanilla
> XORP source code. In any case, could you send your OS and kernel
> version, and your XORP configuration file so I can also try to
> replicate and debug the problem.

If neither of those #defines are met, then I believe CMSG_NXTHDR
is called twice in a row (because it was called before that big
if branch, but the cmsgp is not modified within that if in this case),
without initializing the msg header values.

Here is the patch I have been successfully running with.  Obviously
the asserts can be removed...


[greearb at file-server xorp_local_git]$ git diff
diff --git a/fea/data_plane/io/io_ip_socket.cc b/fea/data_plane/io/io_ip_socket.cc
index 8f27f6e..eba1892 100644
--- a/fea/data_plane/io/io_ip_socket.cc
+++ b/fea/data_plane/io/io_ip_socket.cc
@@ -2467,7 +2467,8 @@ IoIpSocket::send_packet(const string& if_name,
         }
         src_address.copy_out(sndpktinfo->ipi6_addr);
         cmsgp = CMSG_NXTHDR(&_sndmh, cmsgp);
-
+       assert(cmsgp);
+
         //
         // Include the Router Alert option if needed
         //
@@ -2499,6 +2500,10 @@ IoIpSocket::send_packet(const string& if_name,
                                      currentlen);
                 return (XORP_ERROR);
             }
+
+           assert(cmsgp);
+           cmsgp = CMSG_NXTHDR(&_sndmh, cmsgp);
+           assert(cmsgp);

  #else  // ! HAVE_RFC3542 (i.e., the old advanced API)

@@ -2512,15 +2517,17 @@ IoIpSocket::send_packet(const string& if_name,
                 error_msg = c_format("inet6_option_init(IPV6_HOPOPTS) failed");
                 return (XORP_ERROR);
             }
+           assert(cmsgp);
             if (inet6_option_append(cmsgp, ra_opt6, 4, 0)) {
                 error_msg = c_format("inet6_option_append(Router Alert) failed");
                 return (XORP_ERROR);
             }
+           assert(cmsgp);
+           cmsgp = CMSG_NXTHDR(&_sndmh, cmsgp);
+           assert(cmsgp);
  #endif // HAVE_IPV6_MULTICAST_ROUTING

  #endif // ! HAVE_RFC3542
-
-           cmsgp = CMSG_NXTHDR(&_sndmh, cmsgp);
         }

         //


-- 
Ben Greear <greearb at candelatech.com>
Candela Technologies Inc  http://www.candelatech.com



More information about the Xorp-hackers mailing list