]> git.ipfire.org Git - thirdparty/iptables.git/commitdiff
Finally fixed sparc64 counter bug (I hope).
authorRusty Russell <rusty@linuxcare.com.au>
Mon, 4 Sep 2000 09:45:54 +0000 (09:45 +0000)
committerRusty Russell <rusty@rustcorp.com.au>
Mon, 4 Sep 2000 09:45:54 +0000 (09:45 +0000)
libiptc/libiptc.c

index 994815784a616d1b86699c46c1e25f545215fc2b..9db28c581a6d5447ffb8d11d065fcab061385507 100644 (file)
@@ -1445,11 +1445,6 @@ subtract_counters(STRUCT_COUNTERS *answer,
 {
        answer->pcnt = a->pcnt - b->pcnt;
        answer->bcnt = a->bcnt - b->bcnt;
-
-       fprintf(stderr, "pcnt: %llu - %llu = %llu\n",
-               a->pcnt, b->pcnt, answer->pcnt);
-       fprintf(stderr, "bcnt: %llu - %llu = %llu\n",
-               a->bcnt, b->bcnt, answer->bcnt);
 }
 
 int
@@ -1516,15 +1511,6 @@ TC_COMMIT(TC_HANDLE_T *handle)
                return 0;
        }
 
-#if 1
-       fprintf(stderr, "Before adjust:\n");
-       for (i = 0; i < (*handle)->new_number; i++) {
-               fprintf(stderr, "counter %i/%i = %llu,%llu\n",
-                       i, (*handle)->new_number,
-                       repl->counters[i].pcnt,
-                       repl->counters[i].bcnt);
-       }
-#endif
        /* Put counters back. */
        strcpy(newcounters->name, (*handle)->info.name);
        newcounters->num_counters = (*handle)->new_number;
@@ -1561,15 +1547,21 @@ TC_COMMIT(TC_HANDLE_T *handle)
                        break;
                }
        }
-#if 1
-       fprintf(stderr, "After adjust:\n");
-       for (i = 0; i < (*handle)->new_number; i++) {
-               fprintf(stderr, "counter %i/%i = %llu,%llu\n",
-                       i, (*handle)->new_number,
-                       newcounters->counters[i].pcnt,
-                       newcounters->counters[i].bcnt);
+
+#ifdef KERNEL_64_USERSPACE_32
+       {
+               /* Kernel will think that pointer should be 64-bits, and get
+                  padding.  So we accomodate here (assumption: alignment of
+                  `counters' is on 64-bit boundary). */
+               u_int64_t *kernptr = (u_int64_t *)&newcounters->counters;
+               if ((unsigned long)&newcounters->counters % 8 != 0) {
+                       fprintf(stderr,
+                               "counters alignment incorrect! Mail rusty!\n");
+                       abort();
+               }
+               *kernptr = newcounters->counters;
        }
-#endif
+#endif /* KERNEL_64_USERSPACE_32 */
 
        if (setsockopt(sockfd, TC_IPPROTO, SO_SET_ADD_COUNTERS,
                       newcounters, counterlen) < 0) {