]> git.ipfire.org Git - thirdparty/libnl.git/commitdiff
Remove change routine, works flawlessly via add() with NLM_F_REPLACE
authorThomas Graf <tgr@lsx.localdomain>
Thu, 22 May 2008 21:52:53 +0000 (23:52 +0200)
committerThomas Graf <tgr@lsx.localdomain>
Thu, 22 May 2008 21:52:53 +0000 (23:52 +0200)
This breaks the API but is the right thing to do.

include/netlink/route/neighbour.h
lib/route/neigh.c

index d390af1a09b42db0e0e7049035b27d3691b739e9..698539a04a455a0377774bcef614f524f62990e9 100644 (file)
@@ -39,10 +39,6 @@ extern int   rtnl_neigh_add(struct nl_sock *, struct rtnl_neigh *, int);
 extern int     rtnl_neigh_build_add_request(struct rtnl_neigh *, int,
                                             struct nl_msg **);
 
-extern int     rtnl_neigh_change(struct nl_sock *, struct rtnl_neigh *, int);
-extern int     rtnl_neigh_build_change_request(struct rtnl_neigh *, int,
-                                               struct nl_msg **);
-
 extern int     rtnl_neigh_delete(struct nl_sock *, struct rtnl_neigh *, int);
 extern int     rtnl_neigh_build_delete_request(struct rtnl_neigh *, int,
                                                struct nl_msg **);
index 840add71c8e0e919427b0ba7f9c96dddae2a64b7..a87d9761873d8e0abee80920ad05600cdea0bdc4 100644 (file)
@@ -86,7 +86,7 @@
  * // block until the operation has been completed. Alternatively the required
  * // netlink message can be built using rtnl_neigh_build_add_request()
  * // to be sent out using nl_send_auto_complete().
- * rtnl_neigh_add(sk, neigh, NLM_F_REPLACE);
+ * rtnl_neigh_add(sk, neigh, NLM_F_CREATE);
  *
  * // Free the memory
  * rtnl_neigh_put(neigh);
  * // block until the operation has been completed. Alternatively the required
  * // netlink message can be built using rtnl_neigh_build_change_request()
  * // to be sent out using nl_send_auto_complete().
- * rtnl_neigh_change(sk, neigh, 0);
+ * rtnl_neigh_add(sk, neigh, NLM_F_REPLACE);
  *
  * // Free the memory
  * rtnl_neigh_put(neigh);
@@ -568,10 +568,14 @@ static int build_neigh_msg(struct rtnl_neigh *tmpl, int cmd, int flags,
        struct nl_msg *msg;
        struct ndmsg nhdr = {
                .ndm_ifindex = tmpl->n_ifindex,
-               .ndm_family = nl_addr_get_family(tmpl->n_dst),
                .ndm_state = NUD_PERMANENT,
        };
 
+       if (!(tmpl->ce_mask & NEIGH_ATTR_DST))
+               return -NLE_MISSING_ATTR;
+
+       nhdr.ndm_family = nl_addr_get_family(tmpl->n_dst);
+
        if (tmpl->ce_mask & NEIGH_ATTR_STATE)
                nhdr.ndm_state = tmpl->n_state;
 
@@ -618,8 +622,7 @@ nla_put_failure:
 int rtnl_neigh_build_add_request(struct rtnl_neigh *tmpl, int flags,
                                 struct nl_msg **result)
 {
-       return build_neigh_msg(tmpl, RTM_NEWNEIGH, NLM_F_CREATE | flags,
-                              result);
+       return build_neigh_msg(tmpl, RTM_NEWNEIGH, flags, result);
 }
 
 /**
@@ -714,66 +717,6 @@ int rtnl_neigh_delete(struct nl_sock *sk, struct rtnl_neigh *neigh,
 
 /** @} */
 
-/**
- * @name Neighbour Modification
- * @{
- */
-
-/**
- * Build a netlink request message to change neighbour attributes
- * @arg neigh          the neighbour to change
- * @arg flags          additional netlink message flags
- * @arg result         Pointer to store resulting message.
- *
- * Builds a new netlink message requesting a change of a neigh
- * attributes. The netlink message header isn't fully equipped with
- * all relevant fields and must thus be sent out via nl_send_auto_complete()
- * or supplemented as needed.
- *
- * @note Not all attributes can be changed, see
- *       \ref neigh_changeable "Changeable Attributes" for a list.
- *
- * @return 0 on success or a negative error code.
- */
-int rtnl_neigh_build_change_request(struct rtnl_neigh *neigh, int flags,
-                                   struct nl_msg **result)
-{
-       return build_neigh_msg(neigh, RTM_NEWNEIGH, NLM_F_REPLACE | flags,
-                              result);
-}
-
-/**
- * Change neighbour attributes
- * @arg sk             Netlink socket.
- * @arg neigh          neighbour to be changed
- * @arg flags          additional netlink message flags
- *
- * Builds a netlink message by calling rtnl_neigh_build_change_request(),
- * sends the request to the kernel and waits for the next ACK to be
- * received and thus blocks until the request has been fullfilled.
- *
- * @return 0 on sucess or a negative error if an error occured.
- * @note Not all attributes can be changed, see
- *       \ref neigh_changeable "Changeable Attributes" for a list.
- */
-int rtnl_neigh_change(struct nl_sock *sk, struct rtnl_neigh *neigh, int flags)
-{
-       struct nl_msg *msg;
-       int err;
-       
-       if ((err = rtnl_neigh_build_change_request(neigh, flags, &msg)) < 0)
-               return err;
-
-       err = nl_send_auto_complete(sk, msg);
-       nlmsg_free(msg);
-       if (err < 0)
-               return err;
-
-       return nl_wait_for_ack(sk);
-}
-
-/** @} */
-
 /**
  * @name Neighbour States Translations
  * @{