---
name: "umad_set_grh"
section: "3"
platform: "linux"
package: "rdma-core"
version: "65.0-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/umad_set_grh"
---

# umad\_set\_grh(3)

set GRH fields within umad buffer using host ordering

## NAME

umad\_set\_grh - set GRH fields within umad buffer using host ordering

## SYNOPSIS

```
#include <infiniband/umad.h>

int umad_set_grh(void *umad, void *mad_addr);
```

## DESCRIPTION

**umad\_set\_grh()** sets the GRH fields (grh\_present, gid, hop\_limit, traffic\_class, flow\_label) within the specified *umad* buffer based on the *mad\_addr* supplied. The provided *mad\_addr* fields are expected to be in host order. If the *mad\_addr* pointer supplied is NULL, no GRH is set. The argument *mad\_addr* is a pointer to an *ib\_mad\_addr\_t* struct, as specified in *\<infiniband/umad.h\>.* The argument *umad* is a pointer to an *ib\_user\_mad\_t* struct, as specified in *\<infiniband/umad.h\>.*

```
typedef struct ib_mad_addr {
uint32_t qpn;
uint32_t qkey;
uint16_t lid;
uint8_t  sl;
uint8_t  path_bits;
uint8_t  grh_present;
uint8_t  gid_index;
uint8_t  hop_limit;
uint8_t  traffic_class;
uint8_t  gid[16];
uint32_t flow_label;
} ib_mad_addr_t;
```

typedef struct ib\_user\_mad { uint32\_t agent\_id; uint32\_t status; uint32\_t timeout\_ms; uint32\_t retries; uint32\_t length; ib\_mad\_addr\_t addr; uint8\_t  data\[0\]; } ib\_user\_mad\_t;

## RETURN VALUE

**umad\_set\_grh()** returns 0 on success, and a negative value on errors. Currently, there are no errors indicated.

## SEE ALSO

[**umad\_set\_grh\_net**(3)](/umad_set_grh_net/3.md)

## AUTHOR

- Hal Rosenstock \<halr@voltaire.com\>
