net: tcp: Don't increment snd.nxt
[akaros.git] / kern / src / net / udp.c
index 19ddfc1..da58226 100644 (file)
@@ -156,6 +156,15 @@ static void udpconnect(struct conv *c, char **argv, int argc)
        iphtadd(&upriv->ht, c);
 }
 
        iphtadd(&upriv->ht, c);
 }
 
+static void udpbind(struct conv *c, char **argv, int argc)
+{
+       Udppriv *upriv;
+
+       upriv = c->p->priv;
+       Fsstdbind(c, argv, argc);
+       iphtadd(&upriv->ht, c);
+}
+
 static int udpstate(struct conv *c, char *state, int n)
 {
        return snprintf(state, n, "%s qin %d qout %d\n",
 static int udpstate(struct conv *c, char *state, int n)
 {
        return snprintf(state, n, "%s qin %d qout %d\n",
@@ -173,6 +182,14 @@ static void udpannounce(struct conv *c, char **argv, int argc)
        iphtadd(&upriv->ht, c);
 }
 
        iphtadd(&upriv->ht, c);
 }
 
+static void udpbypass(struct conv *cv, char **argv, int argc)
+{
+       Udppriv *upriv = cv->p->priv;
+
+       Fsstdbypass(cv, argv, argc);
+       iphtadd(&upriv->ht, cv);
+}
+
 static void udpcreate(struct conv *c)
 {
        c->rq = qopen(128 * 1024, Qmsg, 0, 0);
 static void udpcreate(struct conv *c)
 {
        c->rq = qopen(128 * 1024, Qmsg, 0, 0);
@@ -314,6 +331,7 @@ void udpkick(void *x, struct block *bp)
                                   ~ptclcsum(bp, UDP4_PHDR_OFF, UDP4_PHDR_SZ));
                        bp->checksum_start = UDP4_IPHDR_SZ;
                        bp->checksum_offset = uh4->udpcksum - uh4->udpsport;
                                   ~ptclcsum(bp, UDP4_PHDR_OFF, UDP4_PHDR_SZ));
                        bp->checksum_start = UDP4_IPHDR_SZ;
                        bp->checksum_offset = uh4->udpcksum - uh4->udpsport;
+                       bp->transport_header_end = UDP4_IPHDR_SZ;
                        bp->flag |= Budpck;
                        uh4->vihl = IP_VER4;
                        ipoput4(f, bp, 0, c->ttl, c->tos, rc);
                        bp->flag |= Budpck;
                        uh4->vihl = IP_VER4;
                        ipoput4(f, bp, 0, c->ttl, c->tos, rc);
@@ -352,6 +370,7 @@ void udpkick(void *x, struct block *bp)
                                   ptclcsum(bp, UDP6_PHDR_OFF,
                                                        dlen + UDP_UDPHDR_SZ + UDP6_PHDR_SZ));
                        memset(uh6, 0, 8);
                                   ptclcsum(bp, UDP6_PHDR_OFF,
                                                        dlen + UDP_UDPHDR_SZ + UDP6_PHDR_SZ));
                        memset(uh6, 0, 8);
+                       bp->transport_header_end = UDP6_IPHDR_SZ;
                        uh6->viclfl[0] = IP_VER6;
                        hnputs(uh6->len, ptcllen);
                        uh6->nextheader = IP_UDPPROTO;
                        uh6->viclfl[0] = IP_VER6;
                        hnputs(uh6->len, ptcllen);
                        uh6->nextheader = IP_UDPPROTO;
@@ -467,6 +486,12 @@ void udpiput(struct Proto *udp, struct Ipifc *ifc, struct block *bp)
                freeblist(bp);
                return;
        }
                freeblist(bp);
                return;
        }
+
+       if (c->state == Bypass) {
+               bypass_or_drop(c, bp);
+               return;
+       }
+
        ucb = (Udpcb *) c->ptcl;
 
        if (c->state == Announced) {
        ucb = (Udpcb *) c->ptcl;
 
        if (c->state == Announced) {
@@ -655,7 +680,9 @@ void udpinit(struct Fs *fs)
        udp->priv = kzmalloc(sizeof(Udppriv), 0);
        udp->name = "udp";
        udp->connect = udpconnect;
        udp->priv = kzmalloc(sizeof(Udppriv), 0);
        udp->name = "udp";
        udp->connect = udpconnect;
+       udp->bind = udpbind;
        udp->announce = udpannounce;
        udp->announce = udpannounce;
+       udp->bypass = udpbypass;
        udp->ctl = udpctl;
        udp->state = udpstate;
        udp->create = udpcreate;
        udp->ctl = udpctl;
        udp->state = udpstate;
        udp->create = udpcreate;
@@ -664,7 +691,7 @@ void udpinit(struct Fs *fs)
        udp->advise = udpadvise;
        udp->stats = udpstats;
        udp->ipproto = IP_UDPPROTO;
        udp->advise = udpadvise;
        udp->stats = udpstats;
        udp->ipproto = IP_UDPPROTO;
-       udp->nc = Nchans;
+       udp->nc = 4096;
        udp->ptclsize = sizeof(Udpcb);
 
        Fsproto(fs, udp);
        udp->ptclsize = sizeof(Udpcb);
 
        Fsproto(fs, udp);