net/sctp/bind_addr.c
Source file repositories/reference/linux-study-clean/net/sctp/bind_addr.c
File Facts
- System
- Linux kernel
- Corpus path
net/sctp/bind_addr.c- Extension
.c- Size
- 14522 bytes
- Lines
- 585
- Domain
- Networking Core
- Bucket
- Sockets, Protocols, Packet Path, And Network Policy
- Inferred role
- Networking Core: implementation source
- Status
- source implementation candidate
Why This File Exists
Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.
- Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/types.hlinux/slab.hlinux/in.hnet/sock.hnet/ipv6.hnet/if_inet6.hnet/sctp/sctp.hnet/sctp/sm.h
Detected Declarations
function sctp_bind_addr_copyfunction list_for_each_entryfunction sctp_bind_addr_dupfunction list_for_each_entryfunction sctp_bind_addr_initfunction sctp_bind_addr_cleanfunction sctp_bind_addr_freefunction sctp_add_bind_addrfunction sctp_del_bind_addrfunction sctp_bind_addrs_to_rawfunction list_for_each_entryfunction formatfunction sctp_bind_addr_matchfunction sctp_bind_addrs_checkfunction list_for_each_entry_rcufunction sctp_bind_addr_conflictfunction sctp_bind_addr_statefunction list_for_each_entry_rcufunction sctp_copy_one_addrfunction sctp_is_anyfunction sctp_in_scopefunction sctp_is_ep_boundallfunction sctp_scope
Annotated Snippet
list_for_each_entry(addr, &src->address_list, list) {
error = sctp_copy_one_addr(net, dest, &addr->a,
SCTP_SCOPE_LINK, gfp,
flags);
if (error < 0)
goto out;
}
}
/* If somehow no addresses were found that can be used with this
* scope, it's an error.
*/
if (list_empty(&dest->address_list))
error = -ENETUNREACH;
out:
if (error)
sctp_bind_addr_clean(dest);
return error;
}
/* Exactly duplicate the address lists. This is necessary when doing
* peer-offs and accepts. We don't want to put all the current system
* addresses into the endpoint. That's useless. But we do want duplicat
* the list of bound addresses that the older endpoint used.
*/
int sctp_bind_addr_dup(struct sctp_bind_addr *dest,
const struct sctp_bind_addr *src,
gfp_t gfp)
{
struct sctp_sockaddr_entry *addr;
int error = 0;
/* All addresses share the same port. */
dest->port = src->port;
list_for_each_entry(addr, &src->address_list, list) {
error = sctp_add_bind_addr(dest, &addr->a, sizeof(addr->a),
1, gfp);
if (error < 0)
break;
}
return error;
}
/* Initialize the SCTP_bind_addr structure for either an endpoint or
* an association.
*/
void sctp_bind_addr_init(struct sctp_bind_addr *bp, __u16 port)
{
INIT_LIST_HEAD(&bp->address_list);
bp->port = port;
}
/* Dispose of the address list. */
static void sctp_bind_addr_clean(struct sctp_bind_addr *bp)
{
struct sctp_sockaddr_entry *addr, *temp;
/* Empty the bind address list. */
list_for_each_entry_safe(addr, temp, &bp->address_list, list) {
list_del_rcu(&addr->list);
kfree_rcu(addr, rcu);
SCTP_DBG_OBJCNT_DEC(addr);
}
}
/* Dispose of an SCTP_bind_addr structure */
void sctp_bind_addr_free(struct sctp_bind_addr *bp)
{
/* Empty the bind address list. */
sctp_bind_addr_clean(bp);
}
/* Add an address to the bind address list in the SCTP_bind_addr structure. */
int sctp_add_bind_addr(struct sctp_bind_addr *bp, union sctp_addr *new,
int new_size, __u8 addr_state, gfp_t gfp)
{
struct sctp_sockaddr_entry *addr;
/* Add the address to the bind address list. */
addr = kzalloc_obj(*addr, gfp);
if (!addr)
return -ENOMEM;
memcpy(&addr->a, new, min_t(size_t, sizeof(*new), new_size));
/* Fix up the port if it has not yet been set.
Annotation
- Immediate include surface: `linux/types.h`, `linux/slab.h`, `linux/in.h`, `net/sock.h`, `net/ipv6.h`, `net/if_inet6.h`, `net/sctp/sctp.h`, `net/sctp/sm.h`.
- Detected declarations: `function sctp_bind_addr_copy`, `function list_for_each_entry`, `function sctp_bind_addr_dup`, `function list_for_each_entry`, `function sctp_bind_addr_init`, `function sctp_bind_addr_clean`, `function sctp_bind_addr_free`, `function sctp_add_bind_addr`, `function sctp_del_bind_addr`, `function sctp_bind_addrs_to_raw`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.