@@ -1032,212 +1032,6 @@ netlink_put_intf_update_msg(struct nl_batch *bth, struct zebra_dplane_ctx *ctx)
1032
1032
return netlink_batch_add_msg (bth , ctx , netlink_intf_msg_encoder , false);
1033
1033
}
1034
1034
1035
- int netlink_interface_addr (struct nlmsghdr * h , ns_id_t ns_id , int startup )
1036
- {
1037
- int len ;
1038
- struct ifaddrmsg * ifa ;
1039
- struct rtattr * tb [IFA_MAX + 1 ];
1040
- struct interface * ifp ;
1041
- void * addr ;
1042
- void * broad ;
1043
- uint8_t flags = 0 ;
1044
- char * label = NULL ;
1045
- struct zebra_ns * zns ;
1046
- uint32_t metric = METRIC_MAX ;
1047
- uint32_t kernel_flags = 0 ;
1048
-
1049
- frrtrace (3 , frr_zebra , netlink_interface_addr , h , ns_id , startup );
1050
-
1051
- zns = zebra_ns_lookup (ns_id );
1052
- ifa = NLMSG_DATA (h );
1053
-
1054
- if (ifa -> ifa_family != AF_INET && ifa -> ifa_family != AF_INET6 ) {
1055
- flog_warn (
1056
- EC_ZEBRA_UNKNOWN_FAMILY ,
1057
- "Invalid address family: %u received from kernel interface addr change: %s" ,
1058
- ifa -> ifa_family , nl_msg_type_to_str (h -> nlmsg_type ));
1059
- return 0 ;
1060
- }
1061
-
1062
- if (h -> nlmsg_type != RTM_NEWADDR && h -> nlmsg_type != RTM_DELADDR )
1063
- return 0 ;
1064
-
1065
- len = h -> nlmsg_len - NLMSG_LENGTH (sizeof (struct ifaddrmsg ));
1066
- if (len < 0 ) {
1067
- zlog_err (
1068
- "%s: Message received from netlink is of a broken size: %d %zu" ,
1069
- __func__ , h -> nlmsg_len ,
1070
- (size_t )NLMSG_LENGTH (sizeof (struct ifaddrmsg )));
1071
- return -1 ;
1072
- }
1073
-
1074
- netlink_parse_rtattr (tb , IFA_MAX , IFA_RTA (ifa ), len );
1075
-
1076
- ifp = if_lookup_by_index_per_ns (zns , ifa -> ifa_index );
1077
- if (ifp == NULL ) {
1078
- if (startup ) {
1079
- /* During startup, failure to lookup the referenced
1080
- * interface should not be an error, so we have
1081
- * downgraded this condition to warning, and we permit
1082
- * the startup interface state retrieval to continue.
1083
- */
1084
- flog_warn (EC_LIB_INTERFACE ,
1085
- "%s: can't find interface by index %d" ,
1086
- __func__ , ifa -> ifa_index );
1087
- return 0 ;
1088
- } else {
1089
- flog_err (EC_LIB_INTERFACE ,
1090
- "%s: can't find interface by index %d" ,
1091
- __func__ , ifa -> ifa_index );
1092
- return -1 ;
1093
- }
1094
- }
1095
-
1096
- /* Flags passed through */
1097
- if (tb [IFA_FLAGS ])
1098
- kernel_flags = * (int * )RTA_DATA (tb [IFA_FLAGS ]);
1099
- else
1100
- kernel_flags = ifa -> ifa_flags ;
1101
-
1102
- if (IS_ZEBRA_DEBUG_KERNEL ) /* remove this line to see initial ifcfg */
1103
- {
1104
- char buf [BUFSIZ ];
1105
- zlog_debug ("%s %s %s flags 0x%x:" , __func__ ,
1106
- nl_msg_type_to_str (h -> nlmsg_type ), ifp -> name ,
1107
- kernel_flags );
1108
- if (tb [IFA_LOCAL ])
1109
- zlog_debug (" IFA_LOCAL %s/%d" ,
1110
- inet_ntop (ifa -> ifa_family ,
1111
- RTA_DATA (tb [IFA_LOCAL ]), buf ,
1112
- BUFSIZ ),
1113
- ifa -> ifa_prefixlen );
1114
- if (tb [IFA_ADDRESS ])
1115
- zlog_debug (" IFA_ADDRESS %s/%d" ,
1116
- inet_ntop (ifa -> ifa_family ,
1117
- RTA_DATA (tb [IFA_ADDRESS ]), buf ,
1118
- BUFSIZ ),
1119
- ifa -> ifa_prefixlen );
1120
- if (tb [IFA_BROADCAST ])
1121
- zlog_debug (" IFA_BROADCAST %s/%d" ,
1122
- inet_ntop (ifa -> ifa_family ,
1123
- RTA_DATA (tb [IFA_BROADCAST ]), buf ,
1124
- BUFSIZ ),
1125
- ifa -> ifa_prefixlen );
1126
- if (tb [IFA_LABEL ] && strcmp (ifp -> name , RTA_DATA (tb [IFA_LABEL ])))
1127
- zlog_debug (" IFA_LABEL %s" ,
1128
- (char * )RTA_DATA (tb [IFA_LABEL ]));
1129
-
1130
- if (tb [IFA_CACHEINFO ]) {
1131
- struct ifa_cacheinfo * ci = RTA_DATA (tb [IFA_CACHEINFO ]);
1132
- zlog_debug (" IFA_CACHEINFO pref %d, valid %d" ,
1133
- ci -> ifa_prefered , ci -> ifa_valid );
1134
- }
1135
- }
1136
-
1137
- /* logic copied from iproute2/ip/ipaddress.c:print_addrinfo() */
1138
- if (tb [IFA_LOCAL ] == NULL )
1139
- tb [IFA_LOCAL ] = tb [IFA_ADDRESS ];
1140
- if (tb [IFA_ADDRESS ] == NULL )
1141
- tb [IFA_ADDRESS ] = tb [IFA_LOCAL ];
1142
-
1143
- /* local interface address */
1144
- addr = (tb [IFA_LOCAL ] ? RTA_DATA (tb [IFA_LOCAL ]) : NULL );
1145
-
1146
- /* is there a peer address? */
1147
- if (tb [IFA_ADDRESS ]
1148
- && memcmp (RTA_DATA (tb [IFA_ADDRESS ]), RTA_DATA (tb [IFA_LOCAL ]),
1149
- RTA_PAYLOAD (tb [IFA_ADDRESS ]))) {
1150
- broad = RTA_DATA (tb [IFA_ADDRESS ]);
1151
- SET_FLAG (flags , ZEBRA_IFA_PEER );
1152
- } else
1153
- /* seeking a broadcast address */
1154
- broad = (tb [IFA_BROADCAST ] ? RTA_DATA (tb [IFA_BROADCAST ])
1155
- : NULL );
1156
-
1157
- /* addr is primary key, SOL if we don't have one */
1158
- if (addr == NULL ) {
1159
- zlog_debug ("%s: Local Interface Address is NULL for %s" ,
1160
- __func__ , ifp -> name );
1161
- return -1 ;
1162
- }
1163
-
1164
- /* Flags. */
1165
- if (kernel_flags & IFA_F_SECONDARY )
1166
- SET_FLAG (flags , ZEBRA_IFA_SECONDARY );
1167
-
1168
- /* Label */
1169
- if (tb [IFA_LABEL ])
1170
- label = (char * )RTA_DATA (tb [IFA_LABEL ]);
1171
-
1172
- if (label && strcmp (ifp -> name , label ) == 0 )
1173
- label = NULL ;
1174
-
1175
- if (tb [IFA_RT_PRIORITY ])
1176
- metric = * (uint32_t * )RTA_DATA (tb [IFA_RT_PRIORITY ]);
1177
-
1178
- /* Register interface address to the interface. */
1179
- if (ifa -> ifa_family == AF_INET ) {
1180
- if (ifa -> ifa_prefixlen > IPV4_MAX_BITLEN ) {
1181
- zlog_err (
1182
- "Invalid prefix length: %u received from kernel interface addr change: %s" ,
1183
- ifa -> ifa_prefixlen ,
1184
- nl_msg_type_to_str (h -> nlmsg_type ));
1185
- return -1 ;
1186
- }
1187
-
1188
- if (h -> nlmsg_type == RTM_NEWADDR )
1189
- connected_add_ipv4 (ifp , flags , (struct in_addr * )addr ,
1190
- ifa -> ifa_prefixlen ,
1191
- (struct in_addr * )broad , label ,
1192
- metric );
1193
- else if (CHECK_FLAG (flags , ZEBRA_IFA_PEER )) {
1194
- /* Delete with a peer address */
1195
- connected_delete_ipv4 (
1196
- ifp , flags , (struct in_addr * )addr ,
1197
- ifa -> ifa_prefixlen , broad );
1198
- } else
1199
- connected_delete_ipv4 (
1200
- ifp , flags , (struct in_addr * )addr ,
1201
- ifa -> ifa_prefixlen , NULL );
1202
- }
1203
-
1204
- if (ifa -> ifa_family == AF_INET6 ) {
1205
- if (ifa -> ifa_prefixlen > IPV6_MAX_BITLEN ) {
1206
- zlog_err (
1207
- "Invalid prefix length: %u received from kernel interface addr change: %s" ,
1208
- ifa -> ifa_prefixlen ,
1209
- nl_msg_type_to_str (h -> nlmsg_type ));
1210
- return -1 ;
1211
- }
1212
- if (h -> nlmsg_type == RTM_NEWADDR ) {
1213
- /* Only consider valid addresses; we'll not get a
1214
- * notification from
1215
- * the kernel till IPv6 DAD has completed, but at init
1216
- * time, Quagga
1217
- * does query for and will receive all addresses.
1218
- */
1219
- if (!(kernel_flags
1220
- & (IFA_F_DADFAILED | IFA_F_TENTATIVE )))
1221
- connected_add_ipv6 (ifp , flags ,
1222
- (struct in6_addr * )addr ,
1223
- (struct in6_addr * )broad ,
1224
- ifa -> ifa_prefixlen , label ,
1225
- metric );
1226
- } else
1227
- connected_delete_ipv6 (ifp , (struct in6_addr * )addr ,
1228
- NULL , ifa -> ifa_prefixlen );
1229
- }
1230
-
1231
- /*
1232
- * Linux kernel does not send route delete on interface down/addr del
1233
- * so we have to re-process routes it owns (i.e. kernel routes)
1234
- */
1235
- if (h -> nlmsg_type != RTM_NEWADDR )
1236
- rib_update (RIB_UPDATE_KERNEL );
1237
-
1238
- return 0 ;
1239
- }
1240
-
1241
1035
/*
1242
1036
* Parse and validate an incoming interface address change message,
1243
1037
* generating a dplane context object.
0 commit comments