All of lore.kernel.org
 help / color / mirror / Atom feed
* openssl build broken for distros without IPv6
@ 2012-04-05 11:36 Miroslav Kes
  2012-04-06  9:06 ` Henning Heinold
  0 siblings, 1 reply; 3+ messages in thread
From: Miroslav Kes @ 2012-04-05 11:36 UTC (permalink / raw)
  To: openembedded-devel

   Hi!
   There is a "feature" in the openembedded/recipes/openssl/openssl.inc
   that criples one of the openssl source files (and breaks the whole
   build) if the distro doesn't support IPv6 .
   do_configure () {
       ...
       eval "${@base_contains('DISTRO_FEATURES', 'ipv6', '', 'sed -i -e
   "/AF_INET6/,/break/d" ${S}/crypto/bio/bss_dgram.c', d)}"
   }
   The application of the sed pattern on the ${S}/crypto/bio/bss_dgram.c
   cuts also a piece of code between the middle of the static int
   dgram_write( ... ) function and the middle of the static long
   dgram_ctrl(...) function.
   In other words, the two functions are "merged" in one combining the
   head of the first function body with the tail of the second function
   body (see the first part of the diff bellow)
   If I save a snapshot of the source tree after the patch task and
   compare it with the result of the configure task, the diff looks like:
   diff openssl-1.0.0e.patch/crypto/bio/bss_dgram.c
   openssl-1.0.0e/crypto/bio/bss_dgram.c
   345,402d344



   <               else if (data->peer.sa.sa_family ==
   AF_INET6)


   <                       peerlen =
   sizeof(data->peer.sa_in6);



   <
   #endif



   < #if defined(NETWARE_CLIB) &&
   defined(NETWARE_BSDSOCK)



   <               ret=sendto(b->num, (char *)in, inl, 0, &data->peer.sa,
   peerlen);


   <
   #else



   <               ret=sendto(b->num, in, inl, 0, &data->peer.sa,
   peerlen);


   <
   #endif



   <
   }



   <



   <
   BIO_clear_retry_flags(b);



   <       if (ret <=
   0)



   <
   {



   <               if
   (BIO_dgram_should_retry(ret))



   <
   {



   <
   BIO_set_retry_write(b);



   <                       data->_errno =
   get_last_socket_error();



   <



   < #if 0 /* higher layers are responsible for querying MTU, if necessary
   */


   <                       if ( data->_errno ==
   EMSGSIZE)



   <                               /* retrieve the new MTU
   */


   <                               BIO_ctrl(b, BIO_CTRL_DGRAM_QUERY_MTU,
   0,
   NULL);


   <
   #endif



   <
   }



   <
   }



   <       return(ret);
   <       }
   <
   < static long dgram_ctrl(BIO *b, int cmd, long num, void *ptr)
   <       {
   <       long ret=1;
   <       int *ip;
   <       struct sockaddr *to = NULL;
   <       bio_dgram_data *data = NULL;
   < #if defined(IP_MTU_DISCOVER) || defined(IP_MTU)
   <       long sockopt_val = 0;
   <       unsigned int sockopt_len = 0;
   < #endif
   < #ifdef OPENSSL_SYS_LINUX
   <       socklen_t addr_len;
   <       union   {
   <               struct sockaddr sa;
   <               struct sockaddr_in s4;
   < #if OPENSSL_USE_IPV6
   <               struct sockaddr_in6 s6;
   < #endif
   <               } addr;
   < #endif
   <
   <       data = (bio_dgram_data *)b->ptr;
   <
   <       switch (cmd)
   <               {
   <       case BIO_CTRL_RESET:
   <               num=0;
   <       case BIO_C_FILE_SEEK:
   <               ret=0;
   <               break;
   451,453d392
   <                               case AF_INET6:
   <
   memcpy(&data->peer,to,sizeof(data->peer.sa_in6));
   <                                       break;
   483,488d421
   <               case AF_INET6:
   <                       sockopt_val = IPV6_PMTUDISC_DO;
   <                       if ((ret = setsockopt(b->num, IPPROTO_IPV6,
   IPV6_MTU_DISCOVER,
   <                               &sockopt_val, sizeof(sockopt_val))) <
   0)
   <                               perror("setsockopt");
   <                       break;
   526,540d458
   <               case AF_INET6:
   <                       if ((ret = getsockopt(b->num, IPPROTO_IPV6,
   IPV6_MTU, (void *)&sockopt_val,
   <                               &sockopt_len)) < 0 || sockopt_val < 0)
   <                               {
   <                               ret = 0;
   <                               }
   <                       else
   <                               {
   <                               /* we assume that the transport
   protocol is UDP and no
   <                                * IPV6 options are used.
   <                                */
   <                               data->mtu = sockopt_val - 8 - 40;
   <                               ret = data->mtu;
   <                               }
   <                       break;
   569,571d486
   <                               case AF_INET6:
   <
   memcpy(&data->peer,to,sizeof(data->peer.sa_in6));
   <                                       break;
   591,593d505
   <                       case AF_INET6:
   <                               ret=sizeof(data->peer.sa_in6);
   <                               break;
   611,613d522
   <                       case AF_INET6:
   <
   memcpy(&data->peer,to,sizeof(data->peer.sa_in6));
   <                               break;
   Regards
   Mira Kes


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: openssl build broken for distros without IPv6
  2012-04-05 11:36 Miroslav Kes
@ 2012-04-06  9:06 ` Henning Heinold
  0 siblings, 0 replies; 3+ messages in thread
From: Henning Heinold @ 2012-04-06  9:06 UTC (permalink / raw)
  To: openembedded-devel

Hi,

the diff is unreadable, but you could have fixed it by using a patch
rather than the sed command.

Bye Henning



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: openssl build broken for distros without IPv6
@ 2012-04-06 11:30 Miroslav Kes
  0 siblings, 0 replies; 3+ messages in thread
From: Miroslav Kes @ 2012-04-06 11:30 UTC (permalink / raw)
  To: openembedded-devel

Once more with the correct subject to keep track of the thread.

> Hi,
>
> the diff is unreadable, but you could have fixed it by using a patch
> rather than the sed command.
>
> Bye Henning

I'm sorry, it looks like, some auto formatting tool split the long lines
and made it unreadable. I'm trying again (see bellow).

I've looked closer in the meantime what the sed command was trying to
achieve. The intention was likely to eliminate IPv6 specific cases in
the C switch command erasing everything between the "case AF_INET6:" and
the corresponding "break;"
The problem is that it uses only the "AF_INET6" string in its pattern to
find the first line to be deleted. If the AF_INET6 macro is used in a
different context in the code, it blindly erases everything until the
next break command.

I think that the whole idea of doing it by sed is bad. The IPv6 code is
surrounded by #if OPENSSL_USE_IPV6 ... #endif so the correct approach
would be to ensure that the preprocessor includes or skips that code.


Mira Kes

Here is the diff again:

345,402d344
<         else if (data->peer.sa.sa_family == AF_INET6)
<             peerlen = sizeof(data->peer.sa_in6);
< #endif
< #if defined(NETWARE_CLIB) && defined(NETWARE_BSDSOCK)
<         ret=sendto(b->num, (char *)in, inl, 0, &data->peer.sa, peerlen);
< #else
<         ret=sendto(b->num, in, inl, 0, &data->peer.sa, peerlen);
< #endif
<         }
<
<     BIO_clear_retry_flags(b);
<     if (ret <= 0)
<         {
<         if (BIO_dgram_should_retry(ret))
<             {
<             BIO_set_retry_write(b);
<             data->_errno = get_last_socket_error();
<
< #if 0 /* higher layers are responsible for querying MTU, if necessary */
<             if ( data->_errno == EMSGSIZE)
<                 /* retrieve the new MTU */
<                 BIO_ctrl(b, BIO_CTRL_DGRAM_QUERY_MTU, 0, NULL);
< #endif
<             }
<         }
<     return(ret);
<     }
<
< static long dgram_ctrl(BIO *b, int cmd, long num, void *ptr)
<     {
<     long ret=1;
<     int *ip;
<     struct sockaddr *to = NULL;
<     bio_dgram_data *data = NULL;
< #if defined(IP_MTU_DISCOVER) || defined(IP_MTU)
<     long sockopt_val = 0;
<     unsigned int sockopt_len = 0;
< #endif
< #ifdef OPENSSL_SYS_LINUX
<     socklen_t addr_len;
<     union    {
<         struct sockaddr    sa;
<         struct sockaddr_in s4;
< #if OPENSSL_USE_IPV6
<         struct sockaddr_in6 s6;
< #endif
<         } addr;
< #endif
<
<     data = (bio_dgram_data *)b->ptr;
<
<     switch (cmd)
<         {
<     case BIO_CTRL_RESET:
<         num=0;
<     case BIO_C_FILE_SEEK:
<         ret=0;
<         break;
451,453d392
<                 case AF_INET6:
<                     memcpy(&data->peer,to,sizeof(data->peer.sa_in6));
<                     break;
483,488d421
<         case AF_INET6:
<             sockopt_val = IPV6_PMTUDISC_DO;
<             if ((ret = setsockopt(b->num, IPPROTO_IPV6, IPV6_MTU_DISCOVER,
<                 &sockopt_val, sizeof(sockopt_val))) < 0)
<                 perror("setsockopt");
<             break;
526,540d458
<         case AF_INET6:
<             if ((ret = getsockopt(b->num, IPPROTO_IPV6, IPV6_MTU,
(void *)&sockopt_val,
<                 &sockopt_len)) < 0 || sockopt_val < 0)
<                 {
<                 ret = 0;
<                 }
<             else
<                 {
<                 /* we assume that the transport protocol is UDP and no
<                  * IPV6 options are used.
<                  */
<                 data->mtu = sockopt_val - 8 - 40;
<                 ret = data->mtu;
<                 }
<             break;
569,571d486
<                 case AF_INET6:
<                     memcpy(&data->peer,to,sizeof(data->peer.sa_in6));
<                     break;
591,593d505
<             case AF_INET6:
<                 ret=sizeof(data->peer.sa_in6);
<                 break;
611,613d522
<             case AF_INET6:
<                 memcpy(&data->peer,to,sizeof(data->peer.sa_in6));
<                 break;



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-04-06 11:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-04-06 11:30 openssl build broken for distros without IPv6 Miroslav Kes
  -- strict thread matches above, loose matches on Subject: below --
2012-04-05 11:36 Miroslav Kes
2012-04-06  9:06 ` Henning Heinold

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.