Rather than store a skeleton IPX header in an mbuf hung off the SPX

PCB, simply embed it in the PCB, avoiding additional memory overhead,
memory allocation overhead, and removing one of the few remaining
uses of dtom() in the network stack.

Restore misplaced spx_ctlinput() from an earlier commit.

MFC after:	1 month
This commit is contained in:
Robert Watson 2009-05-25 11:50:58 +00:00
parent 040eca7b04
commit 905220d58e
2 changed files with 15 additions and 12 deletions

View File

@ -129,7 +129,7 @@ struct spxpcb {
u_short s_mtu; /* Max packet size for this stream */
/* use sequence fields in headers to store sequence numbers for this
connection */
struct ipx *s_ipx;
struct ipx s_ipx;
struct spxhdr s_shdr; /* prototype header to transmit */
#define s_cc s_shdr.spx_cc /* connection control (for EM bit) */
#define s_dt s_shdr.spx_dt /* datastream type */
@ -138,7 +138,7 @@ struct spxpcb {
#define s_seq s_shdr.spx_seq /* sequence number */
#define s_ack s_shdr.spx_ack /* acknowledge number */
#define s_alo s_shdr.spx_alo /* allocation number */
#define s_dport s_ipx->ipx_dna.x_port /* where we are sending */
#define s_dport s_ipx.ipx_dna.x_port /* where we are sending */
struct spxhdr s_rhdr; /* last received header (in effect!)*/
u_short s_rack; /* their acknowledge number */
u_short s_ralo; /* their allocation number */

View File

@ -417,6 +417,13 @@ spx_input(struct mbuf *m, struct ipxpcb *ipxp)
m_freem(m);
}
void
spx_ctlinput(int cmd, struct sockaddr *arg_as_sa, void *dummy)
{
/* Currently, nothing. */
}
int
spx_output(struct spxpcb *cb, struct mbuf *m0)
{
@ -520,7 +527,7 @@ spx_output(struct spxpcb *cb, struct mbuf *m0)
m->m_len = sizeof(struct spx);
m->m_next = m0;
si = mtod(m, struct spx *);
si->si_i = *cb->s_ipx;
si->si_i = cb->s_ipx;
si->si_s = cb->s_shdr;
if ((cb->s_flags & SF_PI) && (cb->s_flags & SF_HO)) {
struct spxhdr *sh;
@ -729,7 +736,7 @@ spx_output(struct spxpcb *cb, struct mbuf *m0)
m->m_len = sizeof(*si);
m->m_pkthdr.len = sizeof(*si);
si = mtod(m, struct spx *);
si->si_i = *cb->s_ipx;
si->si_i = cb->s_ipx;
si->si_s = cb->s_shdr;
si->si_seq = cb->s_smax + 1;
si->si_len = htons(sizeof(*si));
@ -1087,7 +1094,6 @@ spx_attach(struct socket *so, int proto, struct thread *td)
ipxp = sotoipxpcb(so);
ipxp->ipxp_flags |= IPXP_SPX;
cb->s_ipx = mtod(mm, struct ipx *);
cb->s_state = TCPS_LISTEN;
cb->s_smax = -1;
cb->s_swl1 = -1;
@ -1124,7 +1130,6 @@ spx_pcbdetach(struct ipxpcb *ipxp)
KASSERT(cb != NULL, ("spx_pcbdetach: cb == NULL"));
spx_reass_flush(cb);
m_free(dtom(cb->s_ipx));
free(cb, M_PCB);
ipxp->ipxp_pcb = NULL;
}
@ -1490,14 +1495,13 @@ static void
spx_template(struct spxpcb *cb)
{
struct ipxpcb *ipxp = cb->s_ipxpcb;
struct ipx *ipx = cb->s_ipx;
struct sockbuf *sb = &(ipxp->ipxp_socket->so_snd);
IPX_LOCK_ASSERT(ipxp);
ipx->ipx_pt = IPXPROTO_SPX;
ipx->ipx_sna = ipxp->ipxp_laddr;
ipx->ipx_dna = ipxp->ipxp_faddr;
cb->s_ipx.ipx_pt = IPXPROTO_SPX;
cb->s_ipx.ipx_sna = ipxp->ipxp_laddr;
cb->s_ipx.ipx_dna = ipxp->ipxp_faddr;
SPX_LOCK();
cb->s_sid = htons(spx_iss);
spx_iss += SPX_ISSINCR/2;
@ -1519,8 +1523,7 @@ spx_template(struct spxpcb *cb)
/*
* Close a SPIP control block. Wake up any sleepers. We used to free any
* queued packets and cb->s_ipx here, but now we defer that until the pcb is
* discarded.
* queued packets, but now we defer that until the pcb is discarded.
*/
void
spx_close(struct spxpcb *cb)