~ubuntu-branches/ubuntu/lucid/virtualbox-ose/lucid-backports

« back to all changes in this revision

Viewing changes to src/VBox/Devices/Network/slirp/ip_input.c

  • Committer: Bazaar Package Importer
  • Author(s): Felix Geyer
  • Date: 2010-09-24 21:23:00 UTC
  • mfrom: (41.1.5 maverick)
  • Revision ID: james.westby@ubuntu.com-20100924212300-th5owzelwdee5sw0
Tags: 3.2.8-dfsg-2ubuntu1~lucid1
* Backport to lucid.
  - debian/rules: set X11_BACKPORT = lucid

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* $Id: ip_input.c 28800 2010-04-27 08:22:32Z vboxsync $ */
 
1
/* $Id: ip_input.c $ */
2
2
/** @file
3
3
 * NAT - IP input.
4
4
 */
90
90
    struct udphdr *udp = NULL;
91
91
    struct ip *pip = NULL;
92
92
 
93
 
#ifndef VBOX_WITH_SLIRP_BSD_MBUF
94
 
    if (m->m_la)
95
 
        return m->m_la;
96
 
#else
97
93
    struct m_tag *t;
98
94
    if ((t = m_tag_find(m, PACKET_TAG_ALIAS, NULL)) != 0)
99
95
        return (struct libalias *)&t[1];
100
 
#endif
101
96
 
102
97
    return la;
103
98
}
125
120
    {
126
121
        int rc;
127
122
        STAM_PROFILE_START(&pData->StatALIAS_input, b);
128
 
        rc = LibAliasIn(select_alias(pData, m), mtod(m, char *), m->m_len);
 
123
        rc = LibAliasIn(select_alias(pData, m), mtod(m, char *), m_length(m, NULL));
129
124
        STAM_PROFILE_STOP(&pData->StatALIAS_input, b);
130
125
        Log2(("NAT: LibAlias return %d\n", rc));
131
126
        if (m->m_len != RT_N2H_U16(ip->ip_len))
145
140
    if (ip->ip_v != IPVERSION)
146
141
    {
147
142
        ipstat.ips_badvers++;
148
 
        goto bad;
 
143
        goto bad_free_m;
149
144
    }
150
145
 
151
146
    hlen = ip->ip_hl << 2;
154
149
    {
155
150
        /* min header length */
156
151
        ipstat.ips_badhlen++;                     /* or packet too short */
157
 
        goto bad;
 
152
        goto bad_free_m;
158
153
    }
159
154
 
160
155
    /* keep ip header intact for ICMP reply
164
159
    if (cksum(m, hlen))
165
160
    {
166
161
        ipstat.ips_badsum++;
167
 
        goto bad;
 
162
        goto bad_free_m;
168
163
    }
169
164
 
170
165
    /*
174
169
    if (ip->ip_len < hlen)
175
170
    {
176
171
        ipstat.ips_badlen++;
177
 
        goto bad;
 
172
        goto bad_free_m;
178
173
    }
179
174
 
180
175
    NTOHS(ip->ip_id);
189
184
    if (mlen < ip->ip_len)
190
185
    {
191
186
        ipstat.ips_tooshort++;
192
 
        goto bad;
 
187
        goto bad_free_m;
193
188
    }
194
189
 
195
190
    /* Should drop packet if mbuf too long? hmmm... */
200
195
    if (ip->ip_ttl==0 || ip->ip_ttl == 1)
201
196
    {
202
197
        icmp_error(pData, m, ICMP_TIMXCEED, ICMP_TIMXCEED_INTRANS, 0, "ttl");
203
 
        goto bad;
 
198
        goto bad_free_m;
204
199
    }
205
200
 
206
201
    ip->ip_ttl--;
248
243
    STAM_PROFILE_STOP(&pData->StatIP_input, a);
249
244
    return;
250
245
 
251
 
bad:
 
246
bad_free_m:
252
247
    Log2(("NAT: IP datagram to %R[IP4] with size(%d) claimed as bad\n",
253
248
        &ip->ip_dst, ip->ip_len));
254
249
    m_freem(pData, m);
390
385
        fp->ipq_nfrags++;
391
386
    }
392
387
 
393
 
#ifndef VBOX_WITH_SLIRP_BSD_MBUF
394
 
#define GETIP(m)    ((struct ip*)(MBUF_IP_HEADER(m)))
395
 
#else
396
388
#define GETIP(m)    ((struct ip*)((m)->m_pkthdr.header))
397
 
#endif
398
 
 
399
389
 
400
390
    /*
401
391
     * Find a segment which begins after this one does.