Author: tuexen
Date: Sat Oct 14 10:02:59 2017
New Revision: 324615
URL: https://svnweb.freebsd.org/changeset/base/324615

Log:
  Code cleanup, not functional change.
  
  This avoids taking a pointer of a packed structure which allows simpler
  compilation of the userland stack.
  
  MFC after:    1 week

Modified:
  head/sys/netinet/sctp_constants.h
  head/sys/netinet/sctp_indata.c
  head/sys/netinet/sctp_input.c
  head/sys/netinet/sctp_output.c
  head/sys/netinet/sctputil.c
  head/sys/netinet/sctputil.h

Modified: head/sys/netinet/sctp_constants.h
==============================================================================
--- head/sys/netinet/sctp_constants.h   Sat Oct 14 04:27:58 2017        
(r324614)
+++ head/sys/netinet/sctp_constants.h   Sat Oct 14 10:02:59 2017        
(r324615)
@@ -97,10 +97,6 @@ __FBSDID("$FreeBSD$");
  */
 #define SCTP_DEFAULT_VRF_SIZE 4
 
-/* constants for rto calc */
-#define sctp_align_safe_nocopy 0
-#define sctp_align_unsafe_makecopy 1
-
 /* JRS - Values defined for the HTCP algorithm */
 #define ALPHA_BASE     (1<<7)  /* 1.0 with shift << 7 */
 #define BETA_MIN       (1<<6)  /* 0.5 with shift << 7 */

Modified: head/sys/netinet/sctp_indata.c
==============================================================================
--- head/sys/netinet/sctp_indata.c      Sat Oct 14 04:27:58 2017        
(r324614)
+++ head/sys/netinet/sctp_indata.c      Sat Oct 14 10:02:59 2017        
(r324615)
@@ -3058,7 +3058,6 @@ sctp_process_segment_range(struct sctp_tcb *stcb, stru
                                                                            
&stcb->asoc,
                                                                            
tp1->whoTo,
                                                                            
&tp1->sent_rcv_time,
-                                                                           
sctp_align_safe_nocopy,
                                                                            
SCTP_RTT_FROM_DATA);
                                                                        *rto_ok 
= 0;
                                                                }
@@ -4030,7 +4029,6 @@ sctp_express_handle_sack(struct sctp_tcb *stcb, uint32
                                                                    
sctp_calculate_rto(stcb,
                                                                    asoc, 
tp1->whoTo,
                                                                    
&tp1->sent_rcv_time,
-                                                                   
sctp_align_safe_nocopy,
                                                                    
SCTP_RTT_FROM_DATA);
                                                                rto_ok = 0;
                                                        }
@@ -4636,7 +4634,6 @@ hopeless_peer:
                                                                    
sctp_calculate_rto(stcb,
                                                                    asoc, 
tp1->whoTo,
                                                                    
&tp1->sent_rcv_time,
-                                                                   
sctp_align_safe_nocopy,
                                                                    
SCTP_RTT_FROM_DATA);
                                                                rto_ok = 0;
                                                        }

Modified: head/sys/netinet/sctp_input.c
==============================================================================
--- head/sys/netinet/sctp_input.c       Sat Oct 14 04:27:58 2017        
(r324614)
+++ head/sys/netinet/sctp_input.c       Sat Oct 14 10:02:59 2017        
(r324615)
@@ -517,7 +517,7 @@ sctp_process_init_ack(struct mbuf *m, int iphlen, int 
            asoc->primary_destination, SCTP_FROM_SCTP_INPUT + SCTP_LOC_3);
 
        /* calculate the RTO */
-       net->RTO = sctp_calculate_rto(stcb, asoc, net, &asoc->time_entered, 
sctp_align_safe_nocopy,
+       net->RTO = sctp_calculate_rto(stcb, asoc, net, &asoc->time_entered,
            SCTP_RTT_FROM_NON_DATA);
        retval = sctp_send_cookie_echo(m, offset, stcb, net);
        if (retval < 0) {
@@ -639,7 +639,7 @@ sctp_handle_heartbeat_ack(struct sctp_heartbeat_chunk 
        tv.tv_sec = cp->heartbeat.hb_info.time_value_1;
        tv.tv_usec = cp->heartbeat.hb_info.time_value_2;
        /* Now lets do a RTO with this */
-       r_net->RTO = sctp_calculate_rto(stcb, &stcb->asoc, r_net, &tv, 
sctp_align_safe_nocopy,
+       r_net->RTO = sctp_calculate_rto(stcb, &stcb->asoc, r_net, &tv,
            SCTP_RTT_FROM_NON_DATA);
        if (!(r_net->dest_state & SCTP_ADDR_REACHABLE)) {
                r_net->dest_state |= SCTP_ADDR_REACHABLE;
@@ -1487,6 +1487,7 @@ sctp_process_cookie_existing(struct mbuf *m, int iphle
        struct sctp_init_ack_chunk *initack_cp, initack_buf;
        struct sctp_nets *net;
        struct mbuf *op_err;
+       struct timeval old;
        int init_offset, initack_offset, i;
        int retval;
        int spec_flag = 0;
@@ -1647,10 +1648,11 @@ sctp_process_cookie_existing(struct mbuf *m, int iphle
                         * since we did not send a HB make sure we don't
                         * double things
                         */
+                       old.tv_sec = cookie->time_entered.tv_sec;
+                       old.tv_usec = cookie->time_entered.tv_usec;
                        net->hb_responded = 1;
                        net->RTO = sctp_calculate_rto(stcb, asoc, net,
-                           &cookie->time_entered,
-                           sctp_align_unsafe_makecopy,
+                           &old,
                            SCTP_RTT_FROM_NON_DATA);
 
                        if (stcb->asoc.sctp_autoclose_ticks &&
@@ -2367,10 +2369,13 @@ sctp_process_cookie_new(struct mbuf *m, int iphlen, in
        }
        (void)SCTP_GETTIME_TIMEVAL(&stcb->asoc.time_entered);
        if ((netp != NULL) && (*netp != NULL)) {
+               struct timeval old;
+
                /* calculate the RTT and set the encaps port */
+               old.tv_sec = cookie->time_entered.tv_sec;
+               old.tv_usec = cookie->time_entered.tv_usec;
                (*netp)->RTO = sctp_calculate_rto(stcb, asoc, *netp,
-                   &cookie->time_entered, sctp_align_unsafe_makecopy,
-                   SCTP_RTT_FROM_NON_DATA);
+                   &old, SCTP_RTT_FROM_NON_DATA);
        }
        /* respond with a COOKIE-ACK */
        sctp_send_cookie_ack(stcb);
@@ -2936,7 +2941,7 @@ sctp_handle_cookie_ack(struct sctp_cookie_ack_chunk *c
                SCTP_STAT_INCR_GAUGE32(sctps_currestab);
                if (asoc->overall_error_count == 0) {
                        net->RTO = sctp_calculate_rto(stcb, asoc, net,
-                           &asoc->time_entered, sctp_align_safe_nocopy,
+                           &asoc->time_entered,
                            SCTP_RTT_FROM_NON_DATA);
                }
                (void)SCTP_GETTIME_TIMEVAL(&asoc->time_entered);

Modified: head/sys/netinet/sctp_output.c
==============================================================================
--- head/sys/netinet/sctp_output.c      Sat Oct 14 04:27:58 2017        
(r324614)
+++ head/sys/netinet/sctp_output.c      Sat Oct 14 10:02:59 2017        
(r324615)
@@ -5501,6 +5501,7 @@ sctp_send_initiate_ack(struct sctp_inpcb *inp, struct 
        struct sctp_paramhdr *ph;
        union sctp_sockstore *over_addr;
        struct sctp_scoping scp;
+       struct timeval now;
 #ifdef INET
        struct sockaddr_in *dst4 = (struct sockaddr_in *)dst;
        struct sockaddr_in *src4 = (struct sockaddr_in *)src;
@@ -5601,7 +5602,9 @@ do_a_abort:
        memset(&stc, 0, sizeof(struct sctp_state_cookie));
 
        /* the time I built cookie */
-       (void)SCTP_GETTIME_TIMEVAL(&stc.time_entered);
+       (void)SCTP_GETTIME_TIMEVAL(&now);
+       stc.time_entered.tv_sec = now.tv_sec;
+       stc.time_entered.tv_usec = now.tv_usec;
 
        /* populate any tie tags */
        if (asoc != NULL) {

Modified: head/sys/netinet/sctputil.c
==============================================================================
--- head/sys/netinet/sctputil.c Sat Oct 14 04:27:58 2017        (r324614)
+++ head/sys/netinet/sctputil.c Sat Oct 14 10:02:59 2017        (r324615)
@@ -2422,8 +2422,8 @@ uint32_t
 sctp_calculate_rto(struct sctp_tcb *stcb,
     struct sctp_association *asoc,
     struct sctp_nets *net,
-    struct timeval *told,
-    int safe, int rtt_from_sack)
+    struct timeval *old,
+    int rtt_from_sack)
 {
        /*-
         * given an association and the starting time of the current RTT
@@ -2432,19 +2432,8 @@ sctp_calculate_rto(struct sctp_tcb *stcb,
        int32_t rtt;            /* RTT in ms */
        uint32_t new_rto;
        int first_measure = 0;
-       struct timeval now, then, *old;
+       struct timeval now;
 
-       /* Copy it out for sparc64 */
-       if (safe == sctp_align_unsafe_makecopy) {
-               old = &then;
-               memcpy(&then, told, sizeof(struct timeval));
-       } else if (safe == sctp_align_safe_nocopy) {
-               old = told;
-       } else {
-               /* error */
-               SCTP_PRINTF("Huh, bad rto calc call\n");
-               return (0);
-       }
        /************************/
        /* 1. calculate new RTT */
        /************************/

Modified: head/sys/netinet/sctputil.h
==============================================================================
--- head/sys/netinet/sctputil.h Sat Oct 14 04:27:58 2017        (r324614)
+++ head/sys/netinet/sctputil.h Sat Oct 14 10:02:59 2017        (r324615)
@@ -135,7 +135,7 @@ void
 
 uint32_t
 sctp_calculate_rto(struct sctp_tcb *, struct sctp_association *,
-    struct sctp_nets *, struct timeval *, int, int);
+    struct sctp_nets *, struct timeval *, int);
 
 uint32_t sctp_calculate_len(struct mbuf *);
 
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to