---
name: "IP_RECVERR"
section: "2const"
platform: "linux"
package: "man-pages"
version: "6.19-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/IP_RECVERR"
---

# IP\_RECVERR(2const)

extended reliable error message passing

## NAME

IP\_RECVERR - extended reliable error message passing

## LIBRARY

Standard C library (*libc*, *-lc*)

## SYNOPSIS

```
#include <netinet/in.h>  /* Definition of IP* constants */
#include <sys/socket.h>
```

**int setsockopt(int** *sockfd***, IPPROTO\_IP, IP\_RECVERR,**                **const int \****enable***, sizeof(int));** **int getsockopt(int** *sockfd***, IPPROTO\_IP, IP\_RECVERR,**                **int \****enabled***, sizeof(int));**

```
struct sock_extended_err {
    uint32_t  ee_errno;   /* error number */
    uint8_t   ee_origin;  /* where the error originated */
    uint8_t   ee_type;    /* type */
    uint8_t   ee_code;    /* code */
    uint8_t   ee_pad;
    uint32_t  ee_info;    /* additional information */
    uint32_t  ee_data;    /* other data */
    /* More data may follow */
};
```

```
#define SO_EE_ORIGIN_NONE    0
#define SO_EE_ORIGIN_LOCAL   1
#define SO_EE_ORIGIN_ICMP    2
#define SO_EE_ORIGIN_ICMP6   3
```

**struct sockaddr \*SO\_EE\_OFFENDER(struct sock\_extended\_err \*);**

## DESCRIPTION

Enable extended reliable error message passing (default: disabled).

When enabled on a datagram socket, all generated errors will be queued in a per-socket error queue. When the user receives an error from a socket operation, the errors can be received by calling [**recvmsg**(2)](/recvmsg/2.md) with the **MSG\_ERRQUEUE** flag set. The *sock\_extended\_err* structure describing the error will be passed in an ancillary message with the type **IP\_RECVERR** and the level **IPPROTO\_IP**. This is useful for reliable error handling on unconnected sockets. The received data portion of the error queue contains the error packet.

The **IP\_RECVERR** control message contains a *sock\_extended\_err* structure.

- *.ee\_errno*

  contains the *errno* number of the queued error.

- *.ee\_origin*

  is the origin code of where the error originated.

The other fields are protocol-specific.

The macro **SO\_EE\_OFFENDER**() returns a pointer to the address of the network object where the error originated from given a pointer to the ancillary message. If this address is not known, the *.sa\_family* member of the *sockaddr* contains **AF\_UNSPEC** and the other fields of the *sockaddr* are undefined.

IP uses the *sock\_extended\_err* structure as follows:

- •

  *.ee\_origin* is set to **SO\_EE\_ORIGIN\_ICMP** for errors received as an ICMP packet, or **SO\_EE\_ORIGIN\_LOCAL** for locally generated errors. Unknown values should be ignored.

- •

  *.ee\_type* and *.ee\_code* are set from the type and code fields of the ICMP header.

- •

  *.ee\_info* contains the discovered MTU for **EMSGSIZE** errors.

- •

  The message also contains the *sockaddr\_in* of the node caused that the error, which can be accessed with the **SO\_EE\_OFFENDER**() macro.

The *.sin\_family* field of the **SO\_EE\_OFFENDER**() address is **AF\_UNSPEC** when the source was unknown. When the error originated from the network, all IP options ([**IP\_OPTIONS**(2const)](/IP_OPTIONS/2const.md), [**IP\_TTL**(2const)](/IP_TTL/2const.md), etc.) enabled on the socket and contained in the error packet are passed as control messages. The payload of the packet causing the error is returned as normal payload.

TCP has no error queue; **MSG\_ERRQUEUE** is not permitted on **SOCK\_STREAM** sockets. **IP\_RECVERR** is valid for TCP, but all errors are returned by socket function return or **SO\_ERROR** only.

For raw sockets, **IP\_RECVERR** enables passing of all received ICMP errors to the application, otherwise errors are reported only on connected sockets

## ERRORS

See [**IPPROTO\_IP**(2const)](/IPPROTO_IP/2const.md). See [**setsockopt**(2)](/setsockopt/2.md). See [**ip**(7)](/ip/7.md).

## STANDARDS

Linux.

## HISTORY

Linux 2.2.

## SEE ALSO

[**IPPROTO\_IP**(2const)](/IPPROTO_IP/2const.md), [**setsockopt**(2)](/setsockopt/2.md), [**ip**(7)](/ip/7.md)
