Logo Search packages:      
Sourcecode: libnl2 version File versions  Download package

int rtnl_neightbl_build_change_request ( struct rtnl_neightbl old,
struct rtnl_neightbl tmpl,
struct nl_msg **  result 
)

Builds a netlink change request message to change neighbour table attributes

  • old neighbour table to change
  • tmpl template with requested changes
  • result Pointer to store resulting message.
Builds a new netlink message requesting a change of neighbour table attributes. The netlink message header isn't fully equipped with all relevant fields and must be sent out via nl_send_auto_complete() or supplemented as needed. old must point to a neighbour table currently configured in the kernel and tmpl must contain the attributes to be changed set via rtnl_neightbl_set_* functions.

Returns:
0 on success or a negative error code.

Definition at line 448 of file neightbl.c.

References nla_put_nested(), NLA_PUT_STRING, NLA_PUT_U32, NLA_PUT_U64, nlmsg_alloc(), nlmsg_alloc_simple(), nlmsg_append(), nlmsg_free(), rtnl_neightbl::nt_family, rtnl_neightbl::nt_gc_interval, rtnl_neightbl::nt_gc_thresh1, rtnl_neightbl::nt_gc_thresh2, rtnl_neightbl::nt_name, and rtnl_neightbl::nt_parms.

Referenced by rtnl_neightbl_change().

{
      struct nl_msg *m, *parms = NULL;
      struct ndtmsg ndt = {
            .ndtm_family = old->nt_family,
      };

      m = nlmsg_alloc_simple(RTM_SETNEIGHTBL, 0);
      if (!m)
            return -NLE_NOMEM;

      if (nlmsg_append(m, &ndt, sizeof(ndt), NLMSG_ALIGNTO) < 0)
            goto nla_put_failure;

      NLA_PUT_STRING(m, NDTA_NAME, old->nt_name);

      if (tmpl->ce_mask & NEIGHTBL_ATTR_THRESH1)
            NLA_PUT_U32(m, NDTA_THRESH1, tmpl->nt_gc_thresh1);

      if (tmpl->ce_mask & NEIGHTBL_ATTR_THRESH2)
            NLA_PUT_U32(m, NDTA_THRESH2, tmpl->nt_gc_thresh2);

      if (tmpl->ce_mask & NEIGHTBL_ATTR_THRESH2)
            NLA_PUT_U32(m, NDTA_THRESH2, tmpl->nt_gc_thresh2);

      if (tmpl->ce_mask & NEIGHTBL_ATTR_GC_INTERVAL)
            NLA_PUT_U64(m, NDTA_GC_INTERVAL,
                              tmpl->nt_gc_interval);

      if (tmpl->ce_mask & NEIGHTBL_ATTR_PARMS) {
            struct rtnl_neightbl_parms *p = &tmpl->nt_parms;

            parms = nlmsg_alloc();
            if (!parms)
                  goto nla_put_failure;

            if (old->nt_parms.ntp_mask & NEIGHTBLPARM_ATTR_IFINDEX)
                  NLA_PUT_U32(parms, NDTPA_IFINDEX,
                                    old->nt_parms.ntp_ifindex);


            if (p->ntp_mask & NEIGHTBLPARM_ATTR_QUEUE_LEN)
                  NLA_PUT_U32(parms, NDTPA_QUEUE_LEN, p->ntp_queue_len);

            if (p->ntp_mask & NEIGHTBLPARM_ATTR_APP_PROBES)
                  NLA_PUT_U32(parms, NDTPA_APP_PROBES, p->ntp_app_probes);

            if (p->ntp_mask & NEIGHTBLPARM_ATTR_UCAST_PROBES)
                  NLA_PUT_U32(parms, NDTPA_UCAST_PROBES,
                            p->ntp_ucast_probes);

            if (p->ntp_mask & NEIGHTBLPARM_ATTR_MCAST_PROBES)
                  NLA_PUT_U32(parms, NDTPA_MCAST_PROBES,
                            p->ntp_mcast_probes);

            if (p->ntp_mask & NEIGHTBLPARM_ATTR_PROXY_QLEN)
                  NLA_PUT_U32(parms, NDTPA_PROXY_QLEN,
                            p->ntp_proxy_qlen);

            if (p->ntp_mask & NEIGHTBLPARM_ATTR_BASE_REACHABLE_TIME)
                  NLA_PUT_U64(parms, NDTPA_BASE_REACHABLE_TIME,
                            p->ntp_base_reachable_time);

            if (p->ntp_mask & NEIGHTBLPARM_ATTR_RETRANS_TIME)
                  NLA_PUT_U64(parms, NDTPA_RETRANS_TIME,
                            p->ntp_retrans_time);

            if (p->ntp_mask & NEIGHTBLPARM_ATTR_GC_STALETIME)
                  NLA_PUT_U64(parms, NDTPA_GC_STALETIME,
                            p->ntp_gc_stale_time);

            if (p->ntp_mask & NEIGHTBLPARM_ATTR_DELAY_PROBE_TIME)
                  NLA_PUT_U64(parms, NDTPA_DELAY_PROBE_TIME,
                            p->ntp_proxy_delay);

            if (p->ntp_mask & NEIGHTBLPARM_ATTR_ANYCAST_DELAY)
                  NLA_PUT_U64(parms, NDTPA_ANYCAST_DELAY,
                            p->ntp_anycast_delay);

            if (p->ntp_mask & NEIGHTBLPARM_ATTR_PROXY_DELAY)
                  NLA_PUT_U64(parms, NDTPA_PROXY_DELAY,
                                    p->ntp_proxy_delay);

            if (p->ntp_mask & NEIGHTBLPARM_ATTR_LOCKTIME)
                  NLA_PUT_U64(parms, NDTPA_LOCKTIME, p->ntp_locktime);

            if (nla_put_nested(m, NDTA_PARMS, parms) < 0)
                  goto nla_put_failure;

            nlmsg_free(parms);
      }

      *result = m;
      return 0;

nla_put_failure:
      if (parms)
            nlmsg_free(parms);
      nlmsg_free(m);
      return -NLE_MSGSIZE;
}


Generated by  Doxygen 1.6.0   Back to index