Commit 01e85b9f authored by Jon Grimm's avatar Jon Grimm

[SCTP]: enable v6 autobinding.

This is just more address cleanup really, but the sideeffect is that 
this enables the autobinding on PF_INET6 sockets. 
parent eb34f986
...@@ -259,6 +259,7 @@ typedef struct sctp_func { ...@@ -259,6 +259,7 @@ typedef struct sctp_func {
int saddr); int saddr);
int (*addr_valid) (union sctp_addr *); int (*addr_valid) (union sctp_addr *);
sctp_scope_t (*scope) (union sctp_addr *); sctp_scope_t (*scope) (union sctp_addr *);
void (*inaddr_any) (union sctp_addr *, unsigned short);
__u16 net_header_len; __u16 net_header_len;
int sockaddr_len; int sockaddr_len;
sa_family_t sa_family; sa_family_t sa_family;
...@@ -272,6 +273,7 @@ typedef struct sctp_pf { ...@@ -272,6 +273,7 @@ typedef struct sctp_pf {
void (*event_msgname)(sctp_ulpevent_t *, char *, int *); void (*event_msgname)(sctp_ulpevent_t *, char *, int *);
void (*skb_msgname)(struct sk_buff *, char *, int *); void (*skb_msgname)(struct sk_buff *, char *, int *);
int (*af_supported)(sa_family_t); int (*af_supported)(sa_family_t);
struct sctp_func *af;
} sctp_pf_t; } sctp_pf_t;
/* SCTP Socket type: UDP or TCP style. */ /* SCTP Socket type: UDP or TCP style. */
......
...@@ -269,6 +269,14 @@ static int sctp_v6_cmp_saddr(struct dst_entry *dst, union sctp_addr *saddr) ...@@ -269,6 +269,14 @@ static int sctp_v6_cmp_saddr(struct dst_entry *dst, union sctp_addr *saddr)
return ipv6_addr_cmp(&rt->rt6i_src.addr, &saddr->v6.sin6_addr); return ipv6_addr_cmp(&rt->rt6i_src.addr, &saddr->v6.sin6_addr);
} }
/* Initialize addr struct to INADDR_ANY. */
void sctp_v6_inaddr_any(union sctp_addr *addr, unsigned short port)
{
memset(addr, 0x00, sizeof(union sctp_addr));
addr->v6.sin6_family = AF_INET6;
addr->v6.sin6_port = port;
}
/* This function checks if the address is a valid address to be used for /* This function checks if the address is a valid address to be used for
* SCTP. * SCTP.
* *
...@@ -454,6 +462,7 @@ static sctp_func_t sctp_ipv6_specific = { ...@@ -454,6 +462,7 @@ static sctp_func_t sctp_ipv6_specific = {
.cmp_saddr = sctp_v6_cmp_saddr, .cmp_saddr = sctp_v6_cmp_saddr,
.scope = sctp_v6_scope, .scope = sctp_v6_scope,
.addr_valid = sctp_v6_addr_valid, .addr_valid = sctp_v6_addr_valid,
.inaddr_any = sctp_v6_inaddr_any,
.net_header_len = sizeof(struct ipv6hdr), .net_header_len = sizeof(struct ipv6hdr),
.sockaddr_len = sizeof(struct sockaddr_in6), .sockaddr_len = sizeof(struct sockaddr_in6),
.sa_family = AF_INET6, .sa_family = AF_INET6,
...@@ -463,6 +472,7 @@ static sctp_pf_t sctp_pf_inet6_specific = { ...@@ -463,6 +472,7 @@ static sctp_pf_t sctp_pf_inet6_specific = {
.event_msgname = sctp_inet6_event_msgname, .event_msgname = sctp_inet6_event_msgname,
.skb_msgname = sctp_inet6_skb_msgname, .skb_msgname = sctp_inet6_skb_msgname,
.af_supported = sctp_inet6_af_supported, .af_supported = sctp_inet6_af_supported,
.af = &sctp_ipv6_specific,
}; };
/* Initialize IPv6 support and register with inet6 stack. */ /* Initialize IPv6 support and register with inet6 stack. */
......
...@@ -283,6 +283,14 @@ int sctp_v4_cmp_saddr(struct dst_entry *dst, union sctp_addr *saddr) ...@@ -283,6 +283,14 @@ int sctp_v4_cmp_saddr(struct dst_entry *dst, union sctp_addr *saddr)
return (rt->rt_src == saddr->v4.sin_addr.s_addr); return (rt->rt_src == saddr->v4.sin_addr.s_addr);
} }
/* Initialize addr struct to INADDR_ANY. */
void sctp_v4_inaddr_any(union sctp_addr *addr, unsigned short port)
{
addr->v4.sin_family = AF_INET;
addr->v4.sin_addr.s_addr = INADDR_ANY;
addr->v4.sin_port = port;
}
/* This function checks if the address is a valid address to be used for /* This function checks if the address is a valid address to be used for
* SCTP. * SCTP.
* *
...@@ -440,10 +448,13 @@ static int sctp_inet_af_supported(sa_family_t family) ...@@ -440,10 +448,13 @@ static int sctp_inet_af_supported(sa_family_t family)
return (AF_INET == family); return (AF_INET == family);
} }
struct sctp_func sctp_ipv4_specific;
static sctp_pf_t sctp_pf_inet = { static sctp_pf_t sctp_pf_inet = {
.event_msgname = sctp_inet_event_msgname, .event_msgname = sctp_inet_event_msgname,
.skb_msgname = sctp_inet_skb_msgname, .skb_msgname = sctp_inet_skb_msgname,
.af_supported = sctp_inet_af_supported, .af_supported = sctp_inet_af_supported,
.af = &sctp_ipv4_specific,
}; };
...@@ -500,6 +511,7 @@ struct sctp_func sctp_ipv4_specific = { ...@@ -500,6 +511,7 @@ struct sctp_func sctp_ipv4_specific = {
.from_skb = sctp_v4_from_skb, .from_skb = sctp_v4_from_skb,
.cmp_saddr = sctp_v4_cmp_saddr, .cmp_saddr = sctp_v4_cmp_saddr,
.addr_valid = sctp_v4_addr_valid, .addr_valid = sctp_v4_addr_valid,
.inaddr_any = sctp_v4_inaddr_any,
.scope = sctp_v4_scope, .scope = sctp_v4_scope,
.net_header_len = sizeof(struct iphdr), .net_header_len = sizeof(struct iphdr),
.sockaddr_len = sizeof(struct sockaddr_in), .sockaddr_len = sizeof(struct sockaddr_in),
......
...@@ -2377,33 +2377,16 @@ void sctp_put_port(struct sock *sk) ...@@ -2377,33 +2377,16 @@ void sctp_put_port(struct sock *sk)
static int sctp_autobind(struct sock *sk) static int sctp_autobind(struct sock *sk)
{ {
union sctp_addr autoaddr; union sctp_addr autoaddr;
int addr_len = 0; struct sctp_func *af;
unsigned short port;
memset(&autoaddr, 0, sizeof(union sctp_addr));
switch (sk->family) { /* Initialize a local sockaddr structure to INADDR_ANY. */
case PF_INET: af = sctp_sk(sk)->pf->af;
autoaddr.v4.sin_family = AF_INET;
autoaddr.v4.sin_addr.s_addr = INADDR_ANY;
autoaddr.v4.sin_port = htons(inet_sk(sk)->num);
addr_len = sizeof(struct sockaddr_in);
break;
case PF_INET6: port = htons(inet_sk(sk)->num);
SCTP_V6( af->inaddr_any(&autoaddr, port);
/* FIXME: Write me for v6! */
BUG();
autoaddr.v6.sin6_family = AF_INET6;
autoaddr.v6.sin6_port = htons(inet_sk(sk)->num);
addr_len = sizeof(struct sockaddr_in6);
);
break;
default: /* This should not happen. */
break;
};
return sctp_do_bind(sk, &autoaddr, addr_len); return sctp_do_bind(sk, &autoaddr, af->sockaddr_len);
} }
/* Parse out IPPROTO_SCTP CMSG headers. Perform only minimal validation. /* Parse out IPPROTO_SCTP CMSG headers. Perform only minimal validation.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment