I'm diving int IPv6 code to get it working. These are trivial
cleanups that I don't want to obscure potential future changes
that would be more substantive.

Remove redundant or unused headers, whitespace cleanups, etc.

Signed-off-by: Dan Cross <[email protected]>
---
 kern/src/net/icmp6.c | 58 +++++++++++++++++++++-------------------------------
 kern/src/net/ipv6.c  | 54 +++++++++++++-----------------------------------
 2 files changed, 37 insertions(+), 75 deletions(-)

diff --git a/kern/src/net/icmp6.c b/kern/src/net/icmp6.c
index 3b2c23b..5e04e44 100644
--- a/kern/src/net/icmp6.c
+++ b/kern/src/net/icmp6.c
@@ -26,18 +26,11 @@
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 
THE
  * SOFTWARE. */
 
-#include <vfs.h>
-#include <kfs.h>
-#include <slab.h>
 #include <kmalloc.h>
-#include <kref.h>
 #include <string.h>
 #include <stdio.h>
-#include <assert.h>
+#include <syscall.h>
 #include <error.h>
-#include <cpio.h>
-#include <pmap.h>
-#include <smp.h>
 #include <ip.h>
 
 struct ICMPpkt {
@@ -52,10 +45,6 @@ struct ICMPpkt {
  * We have been naming the struct
  * members and just using the extra level of deref
  * e.g. i->x becomes i->i6->x.
- * I'm going to use insert the structs into
- * this because it's just a lot easier, and
- * maybe someday gcc will grow up and me more
- * like Plan 9 C.
  */
 struct IPICMP {
 /*
@@ -347,10 +336,9 @@ static void icmpctl6(struct conv *c, char **argv, int argc)
 {
        Icmpcb6 *icb = (Icmpcb6*)c->ptcl;
 
-       if ((argc == 1) && strcmp(argv[0], "headers") == 0)
-               icb->headers = 6;
-       else
-               error(EINVAL, "unknown command to %s", __func__);
+       if ((argc != 1) || strcmp(argv[0], "headers") != 0)
+               error(EINVAL, "unknown command to icmpctl6");
+       icb->headers = 6;
 }
 
 static void goticmpkt6(struct Proto *icmp, struct block *bp, int muxkey)
@@ -396,14 +384,16 @@ static struct block *mkechoreply6(struct block *bp)
 
 /*
  * sends out an ICMPv6 neighbor solicitation
- *     suni == SRC_UNSPEC or SRC_UNI, 
+ *     suni == SRC_UNSPEC or SRC_UNI,
  *     tuni == TARG_MULTI => multicast for address resolution,
  *     and tuni == TARG_UNI => neighbor reachability.
  */
 
 extern void
-icmpns(struct Fs *f, uint8_t * src, int suni, uint8_t * targ, int tuni,
-          uint8_t * mac)
+icmpns(struct Fs *f,
+       uint8_t *src, int suni,
+       uint8_t *targ, int tuni,
+       uint8_t *mac)
 {
        struct block *nbp;
        struct Ndpkt *np;
@@ -449,7 +439,7 @@ icmpns(struct Fs *f, uint8_t * src, int suni, uint8_t * 
targ, int tuni,
  */
 extern void
 icmpna(struct Fs *f, uint8_t * src, uint8_t * dst, uint8_t * targ,
-          uint8_t * mac, uint8_t flags)
+       uint8_t * mac, uint8_t flags)
 {
        struct block *nbp;
        struct Ndpkt *np;
@@ -482,7 +472,7 @@ icmpna(struct Fs *f, uint8_t * src, uint8_t * dst, uint8_t 
* targ,
 
 extern void
 icmphostunr(struct Fs *f, struct Ipifc *ifc,
-                       struct block *bp, int code, int free)
+            struct block *bp, int code, int free)
 {
        struct block *nbp;
        struct IPICMP *np;
@@ -550,10 +540,10 @@ extern void icmpttlexceeded6(struct Fs *f, struct Ipifc 
*ifc, struct block *bp)
 
        if (ipv6anylocal(ifc, np->src)) {
                netlog(f, Logicmp, "send icmpttlexceeded6 -> s%I d%I\n", p->src,
-                          p->dst);
+                      p->dst);
        } else {
                netlog(f, Logicmp, "icmpttlexceeded6 fail -> s%I d%I\n", p->src,
-                          p->dst);
+                      p->dst);
                return;
        }
 
@@ -561,7 +551,7 @@ extern void icmpttlexceeded6(struct Fs *f, struct Ipifc 
*ifc, struct block *bp)
        np->type = TimeExceedV6;
        np->code = 0;
        memmove(nbp->rp + sizeof(struct IPICMP), bp->rp,
-                       sz - sizeof(struct IPICMP));
+               sz - sizeof(struct IPICMP));
        set_cksum(nbp);
        np->ttl = HOP_LIMIT;
        np->vcf[0] = 0x06 << 4;
@@ -587,12 +577,11 @@ extern void icmppkttoobig6(struct Fs *f, struct Ipifc 
*ifc, struct block *bp)
        nbp = newIPICMP(sz);
        np = (struct IPICMP *)nbp->rp;
 
-       if (ipv6anylocal(ifc, np->src)) {
-               netlog(f, Logicmp, "send icmppkttoobig6 -> s%I d%I\n", p->src, 
p->dst);
-       } else {
+       if (!ipv6anylocal(ifc, np->src)) {
                netlog(f, Logicmp, "icmppkttoobig6 fail -> s%I d%I\n", p->src, 
p->dst);
                return;
        }
+       netlog(f, Logicmp, "send icmppkttoobig6 -> s%I d%I\n", p->src, p->dst);
 
        memmove(np->dst, p->src, IPaddrlen);
        np->type = PacketTooBigV6;
@@ -612,7 +601,7 @@ extern void icmppkttoobig6(struct Fs *f, struct Ipifc *ifc, 
struct block *bp)
  */
 static int
 valid(struct Proto *icmp, struct Ipifc *ifc,
-         struct block *bp, Icmppriv6 * ipriv)
+      struct block *bp, Icmppriv6 * ipriv)
 {
        int sz, osz, unsp, n, ttl, iplen;
        int pktsz = BLEN(bp);
@@ -846,7 +835,7 @@ static void icmpiput6(struct Proto *icmp, struct Ipifc 
*ipifc, struct block *bp)
 
                case RouterAdvert:
                case RouterSolicit:
-                       /* using lsrc as a temp, munge hdr for goticmp6 
+                       /* using lsrc as a temp, munge hdr for goticmp6
                           memmove(lsrc, p->src, IPaddrlen);
                           memmove(p->src, p->dst, IPaddrlen);
                           memmove(p->dst, lsrc, IPaddrlen); */
@@ -890,10 +879,10 @@ static void icmpiput6(struct Proto *icmp, struct Ipifc 
*ipifc, struct block *bp)
                case NbrAdvert:
                        np = (struct Ndpkt *)p;
 
-                       /* if the target address matches one of the local 
interface 
-                        * address and the local interface address has 
tentative bit set, 
-                        * then insert into ARP table. this is so the 
duplication address 
-                        * detection part of ipconfig can discover duplication 
through 
+                       /* if the target address matches one of the local 
interface
+                        * address and the local interface address has 
tentative bit set,
+                        * then insert into ARP table. this is so the 
duplication address
+                        * detection part of ipconfig can discover duplication 
through
                         * the arp table
                         */
                        lifc = iplocalonifc(ipifc, np->target);
@@ -932,9 +921,8 @@ int icmpstats6(struct Proto *icmp6, char *buf, int len)
                if (icmpnames6[i])
                        p = seprintf(p, e, "%s: %u %u\n", icmpnames6[i], 
priv->in[i],
                                                 priv->out[i]);
-/*             else
+               else
                        p = seprintf(p, e, "%d: %u %u\n", i, priv->in[i], 
priv->out[i]);
-*/
        }
        return p - buf;
 }
diff --git a/kern/src/net/ipv6.c b/kern/src/net/ipv6.c
index e25e2dd..e2e54ff 100644
--- a/kern/src/net/ipv6.c
+++ b/kern/src/net/ipv6.c
@@ -6,7 +6,7 @@
  *
  * Modified for the Akaros operating system:
  * Copyright (c) 2013-2014 The Regents of the University of California
- * Copyright (c) 2013-2015 Google Inc.
+ * Copyright (c) 2013-2016 Google Inc.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to 
deal
@@ -24,34 +24,10 @@
  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
FROM,
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 
THE
- * SOFTWARE. */
-
-#include <vfs.h>
-#include <kfs.h>
-#include <slab.h>
-#include <kmalloc.h>
-#include <kref.h>
-#include <string.h>
-#include <stdio.h>
-#include <assert.h>
-#include <error.h>
-#include <cpio.h>
-#include <pmap.h>
-#include <smp.h>
-#include <ip.h>
+ * SOFTWARE.
+ */
 
-#include <vfs.h>
-#include <kfs.h>
-#include <slab.h>
-#include <kmalloc.h>
-#include <kref.h>
-#include <string.h>
-#include <stdio.h>
-#include <assert.h>
 #include <error.h>
-#include <cpio.h>
-#include <pmap.h>
-#include <smp.h>
 #include <ip.h>
 
 enum {
@@ -74,7 +50,7 @@ enum {
 struct fragment6;
 
 struct block *ip6reassemble(struct IP *, int unused_int, struct block *,
-                                                       struct ip6hdr *);
+                            struct ip6hdr *);
 void ipfragfree6(struct IP *, struct fragment6 *);
 struct fragment6 *ipfragallo6(struct IP *);
 static struct block *procxtns(struct IP *ip, struct block *bp, int doreasm);
@@ -169,16 +145,16 @@ struct IP {
 };
 
 int
-ipoput6(struct Fs *f,
-               struct block *bp, int gating, int ttl, int tos, struct conv *c)
+ipoput6(struct Fs *f, struct block *bp,
+        int gating, int ttl, int tos, struct conv *c)
 {
        ERRSTACK(1);
        int tentative;
        struct Ipifc *ifc;
        uint8_t *gate, nexthdr;
        struct ip6hdr *eh;
-       int medialen, len, chunk, uflen, flen, seglen, lid, offset, fragoff,
-               morefrags, blklen;
+       int medialen, len, chunk, uflen, flen, seglen, lid, offset, fragoff;
+       int morefrags, blklen;
        struct route *r, *sr;
        struct fraghdr6 fraghdr;
        struct block *xp, *nb;
@@ -213,7 +189,6 @@ ipoput6(struct Fs *f,
        }
 
        if (len >= IP_MAX) {
-//      print("len > IP_MAX, free\n");
                ip->stats[OutDiscards]++;
                netlog(f, Logip, "exceeded ip max size %I\n", eh->dst);
                goto free;
@@ -221,7 +196,6 @@ ipoput6(struct Fs *f,
 
        r = v6lookup(f, eh->dst, c);
        if (r == NULL) {
-//      print("no route for %I, src %I free\n", eh->dst, eh->src);
                ip->stats[OutNoRoutes]++;
                netlog(f, Logip, "no interface %I\n", eh->dst);
                rv = -1;
@@ -272,12 +246,11 @@ ipoput6(struct Fs *f,
 
        if (gating)
                if (ifc->reassemble <= 0) {
-
-                       /* v6 intermediate nodes are not supposed to fragment 
pkts;
-                          we fragment if ifc->reassemble is turned on; an 
exception
-                          needed for nat.
+                       /*
+                        * v6 intermediate nodes are not supposed to fragment 
pkts;
+                        * we fragment if ifc->reassemble is turned on; an 
exception
+                        * needed for nat.
                         */
-
                        ip->stats[OutDiscards]++;
                        icmppkttoobig6(f, ifc, bp);
                        netlog(f, Logip, "%I: gated pkts not fragmented\n", 
eh->dst);
@@ -595,7 +568,7 @@ struct block *procopts(struct block *bp)
 }
 
 struct block *ip6reassemble(struct IP *ip, int uflen, struct block *bp,
-                                                       struct ip6hdr *ih)
+                            struct ip6hdr *ih)
 {
 
        int fend, offset;
@@ -769,5 +742,6 @@ struct block *ip6reassemble(struct IP *ip, int uflen, 
struct block *bp,
                pktposn += BKFG(bl)->flen;
        }
        qunlock(&ip->fraglock6);
+
        return NULL;
 }
-- 
2.7.0.rc3.207.g0ac5344

-- 
You received this message because you are subscribed to the Google Groups 
"Akaros" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to