+static int rtnl_set_properties(sd_rtnl *rtnl, int ifindex, const char *name, const char *mac, unsigned int mtu) {
+ _cleanup_sd_rtnl_message_unref_ sd_rtnl_message *message;
+ bool need_update;
+ int r;
+
+ assert(rtnl);
+ assert(ifindex > 0);
+
+ r = sd_rtnl_message_link_new(RTM_NEWLINK, ifindex, 0, 0, &message);
+ if (r < 0)
+ return r;
+
+ if (name) {
+ r = sd_rtnl_message_append(message, IFLA_IFNAME, name);
+ if (r < 0)
+ return r;
+
+ need_update = true;
+ }
+
+ if (mac) {
+ r = sd_rtnl_message_append(message, IFLA_ADDRESS, ether_aton(mac));
+ if (r < 0)
+ return r;
+
+ need_update = true;
+ }
+
+ if (mtu > 0) {
+ r = sd_rtnl_message_append(message, IFLA_MTU, &mtu);
+ if (r < 0)
+ return r;
+
+ need_update = true;
+ }
+
+ if (need_update) {
+ r = sd_rtnl_send_with_reply_and_block(rtnl, message, 250 * USEC_PER_MSEC, NULL);
+ if (r < 0)
+ return r;
+ }
+
+ return 0;
+}
+